您应该
cURL为此目的使用
cURL实现名为cookie
jar的功能,该功能允许将cookie保存在文件中,并将其重新用于后续请求。
这里有一个简短的代码片段,介绍了如何实现:
$ckfile = tempnam ("/tmp", "CURLcookie");$ch = curl_init ("http://somedomain.com/");curl_setopt ($ch, CURLOPT_cookieJAR, $ckfile); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);$output = curl_exec ($ch);$ch = curl_init ("http://somedomain.com/cookiepage.php");curl_setopt ($ch, CURLOPT_cookieFILE, $ckfile); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);$output = curl_exec ($ch);注意 :必须注意,您应该已安装pecl扩展名(或用PHP编译),否则您将无法访问cURL API。



