curl提交请求时,如何把cookie带过去
curl请求有一个CURLOPT_COOKIE参数,把获取到的cookie内容,通过字符串组装,赋值给这个参数就可以了
例子: $defaults = array(
CURLOPT_URL => $url . (strpos($url, '?') === FALSE ? '?' : '') . http_build_query($get),
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 15,
CURLOPT_SSLVERSION => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_COOKIE => "PHPSESSID=bcba97d4d227bad4483402;__guid=2534316;f192=eyJ1aWQ;",
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));