【发布时间】:2014-07-17 11:40:33
【问题描述】:
我使用 php curl 向服务器(星号 rawman)发送请求,这是服务器响应:
HTTP/1.1 200 OK
Server: Asterisk/11.9.0
Date: Wed, 28 May 2014 09:36:51 GMT
Connection: close
Cache-Control: no-cache, no-store
Content-Length: 55
Content-type: text/plain
Cache-Control: no-cache;
Set-Cookie: mansession_id="383b2ccc"; Version=1; Max-Age=60
Pragma: SuppressEvents
这里服务器在客户端系统上设置了一个cookie:Set-Cookie: mansession_id=383b2ccc。
在下一个请求中,我必须发送此 cookie 以通过身份验证...但我不知道此 cookie 在哪里?以及如何发送? 在浏览器中它的工作,因为浏览器自动发送cookie,但在PHP CURL中我有一个问题
【问题讨论】:
-
手册说使用 curl_setopt 和 CURLOPT_COOKIE 选项。见php.net/manual/es/function.curl-setopt.php
-
您还可以在此处找到 vvondra 的示例:stackoverflow.com/questions/10570341/…