我需要从URL的http请求标头中获取所有cookie详细信息。如何使用CURL PHP获取所有cookie内容?谁能帮帮我。
谢谢!
试试这个
$ch = curl_init('http://www.google.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// get headers too with this line
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec($ch);
// get cookie
preg_match('/^Set-Cookie:'s*([^;]*)/mi', $result, $m);
parse_str($m[0], $cookies);
var_dump($cookies);