Im using curl through php to fetch a url. I am successfully able to download the page, headers and all. However, the cookies returned by any page do not get saved to the spe
Thanks everyone for all the help. However, the problem was something else entirely. I probably should have mentioned that I am working on a Windows server and cURL was unable to read the path to cookie.txt
.
Using:
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
instead of:
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
solved the problem.
Use an absolute path to the cookie jar file so that you're sure where it is saved and thus you know you have the right permission to write there.
curl stores all cookies it knows of to the file, including so called session cookies (that are without an expiry time)