为什么PHP cURL没有设置cookie?

时间:2015-10-26 12:19:40

标签: php curl cookies

我正在处理两个后续请求,第一个请求是登录,此请求设置登录会话cookie。

第二个请求是常规请求,我希望第一个请求中的cookie已经设置好。

问题是,尽管远程服务器发送了set-cookie标头,但第一次请求时cURL并未设置cookie

以下是处理第一个请求的详细结果

> POST /account/login HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8
Host: forwp.accounts.clickbank.com
Accept: */*
Referer: http://www.bing.com/
Content-Length: 90
Content-Type: application/x-www-form-urlencoded

* upload completely sent off: 90 out of 90 bytes
< HTTP/1.1 302 Found
< Date: Mon, 26 Oct 2015 12:03:17 GMT
* Server Apache is not blacklisted
< Server: Apache
< SET-COOKIE: token=Zm9yd3A6MTQ0NTg5Njk5NzkxOTowMzFhZWQzM2NmYzk0YmQ5MDY0YjEyMzQzOWU1NmZmMQ; Path=/; Domain=forwp.accounts.clickbank.com; Secure; HttpOnly;
< Set-Cookie: JSESSIONID=72878AC21A7658ADC34514BB1CD9A936.AW1; Path=/; Secure; HttpOnly
< Location: https://forwp.accounts.clickbank.com/account/mainMenu.htm
< Content-Length: 0

在我的本地PC上运行相同的请求,它设置cookie没有任何问题。

* upload completely sent off: 124 out of 124 bytes
< HTTP/1.1 302 Found
< Date: Mon, 26 Oct 2015 12:04:45 GMT
* Server Apache is not blacklisted
< Server: Apache
* Added cookie token="c3dlZXRoZWF0bToxNDQ1ODk3MDg1OTQ2OjRjNjhmMGMzODIzZmJmOTVhNWYzMzMxNzUyNmY4NWY4" for domain sweetheatm.accounts.clickbank.com, path /, expire 0
< SET-COOKIE: token=c3dlZXRoZWF0bToxNDQ1ODk3MDg1OTQ2OjRjNjhmMGMzODIzZmJmOTVhNWYzMzMxNzUyNmY4NWY4; Path=/; Domain=sweetheatm.accounts.clickbank.com; Secure; HttpOnly;
* Added cookie JSESSIONID="7E3C5B212D0C1428102A65BDAE57F100.AW1" for domain sweetheatm.accounts.clickbank.com, path /, expire 0
< Set-Cookie: JSESSIONID=7E3C5B212D0C1428102A65BDAE57F100.AW1; Path=/; Secure; HttpOnly
< Location: https://sweetheatm.accounts.clickbank.com/account/mainMenu.htm
< Content-Length: 0

可能是什么问题?

0 个答案:

没有答案