PHP & cURL: is it possible to get a cookie into variable instead of file without parsing headers?
Lets try this with a single curl handle($ch
):
Making my first request:
$url= "http://www.google.com";$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);curl_setopt ($ch, CURLOPT_COOKIEJAR, '-'); // <-- see here$result = curl_exec($ch);// remember i didn't close the curl yet!
Now make another curl request with the same handle:
$url= "http://www.google.com";curl_setopt($ch, CURLOPT_URL,$url);$result = curl_exec($ch);// if you are done, you can close it.curl_close($ch);
In this example, I have used the -
for the cookiejar. Which means it will not use any file. So during second curl request, it will use the cookiejar of previous call.
One problem: It will print the cookie jar values into std-output.