这是我的代码:
$ch = curl_init('http://www1.macys.com/index.ognc');
curl_setopt($ch,CURLOPT_COOKIE,"shippingCountry=US; currency=USD");
curl_setopt ($ch, CURLOPT_COOKIEFILE, "C:/cookie-techenclave.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/cookie-techenclave.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Follow redirects
curl_setopt($ch, CURLOPT_MAXREDIRS, 8); // Limit redirections to four
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return in string
$pageString = curl_exec($ch);
curl_close($ch) ;
我尝试设置的 2 个 cookie 未设置。我用netcat对此进行了测试。这是 netcat 捕获的输出。
D:\php\L.c.MSQL.E.T.DVD\EF\SQL> "D:\My Downloads\apps\nc111nt\nc.exe" -l -p 80
GET /beauty/index_template.php HTTP/1.1
User-Agent: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.10.229 Version/11.64
Host: localhost
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-x
bitmap, */*;q=0.1
Accept-Language: en-US,en;q=0.9
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
可以看出,那里没有 cookie 标头。我究竟做错了什么?我还能尝试什么?我尝试捕获和设置所有标题,但我尝试设置的 cookie 再次没有任何效果。
谢谢