[英]PHP CURL | Header Set-Cookie
I send a request to the server ( asterisk rawman ) using php curl, here is server response: 我使用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
here the server set a cookie on client system: Set-Cookie: mansession_id=383b2ccc
. 在这里,服务器在客户端系统上设置cookie:
Set-Cookie: mansession_id=383b2ccc
。
In the next request i have to send this cookie for pass the authentication... But i don't know where is this cookie ? 在下一个请求中,我必须发送此cookie以通过身份验证...但是我不知道此cookie在哪里? and how i can send that ?
以及我该如何发送呢? In the browser its work because browser send the cookie automatically, but in PHP CURL i have a problem
在浏览器中它的工作是因为浏览器自动发送cookie,但是在PHP CURL中我遇到了问题
Adapting vvondra's response to your case you would get something like: 将vvondra的回复适应您的情况,您将获得以下信息:
You can use curl_setopt with the CURLOPT_COOKIE constant: 您可以将curl_setopt与CURLOPT_COOKIE常量一起使用:
<?php
// create a new cURL resource
$ch = curl_init();
// cookies to be sent
curl_setopt($ch, CURLOPT_COOKIE, "mansession_id=383b2ccc");
您可以使用CURLOPT_COOKIEFILE来仅启用curl句柄中的“ cookie引擎”,并且如果希望在完成处理后将cookie实际保存在某个位置,则可以使用CURLOPT_COOKIEJAR。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.