FreeBSD下的PHP版本5.4.19
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //returns true
curl_setopt($ch, CURLOPT_HEADER, true); //returns true
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6'); //returns true
curl_setopt($ch, CURLOPT_TIMEOUT, 100); //returns true
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //returns true
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //returns true
var_dump(curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) ); //true
var_dump( curl_setopt($ch, CURLOPT_COOKIESESSION, 1) ); //returns false ????
var_dump( curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie') ); //returns false ????
var_dump( curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookie') ); //returns false ????
var_dump( curl_setopt($ch, CURLINFO_HEADER_OUT, true) ); //true
我也注意到,即使没有CURLOPT_COOKIESESSION,CURLOPT_COOKIEJAR,CURLOPT_COOKIEFILE - Curl也没有在单个处理程序中的请求之间传递任何cookie。 这是一些标题日志,以了解我在说什么:
GET /login.php HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
Host: domain.com
Accept: */*
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Thu, 28 Nov 2013 08:25:57 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: PHPSESSID=bev3mvr9s27jgq5vvm43s56pb2; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: go.php?PHPSESSID=bev3mvr9s27jgq5vvm43s56pb2
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Thu, 28 Nov 2013 08:25:57 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: PHPSESSID=m8uddnk1q55s634fu7frnt2lo3; path=/
#session cookie has changed; Curl didn't use PHPSESSID cookie from login.php
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: login.php
更新:我在其他主机上尝试了相同的代码 - 一切正常。唔...
答案 0 :(得分:0)
我不知道为什么,但Curl是在没有cookie支持的情况下编译的。只需用--enable-cookies
重新安装它 - 就是这样。