Good day! I have a tiny question about saving cookies to file with GET request. It only appears to be working with POST request. The following code performs a GET request to Google.com, it *should* get some cookies from there, but cURL doesn't want to save them into a file <?php $ch = curl_init("http://www.google.com"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFile"); curl_exec($ch); ?> PHP: This one performs a POST request and successfully saves cookies into a file (it's just a dummy example) <?php $ch = curl_init("http://www.google.com"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFile"); curl_setopt($ch, CURLOPT_POSTFIELDS, "q=searchQuery"); curl_exec($ch); ?> PHP: Now, to ensure that GET request DOES get some cookies, here's a code for multi-action in one cURL session. <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.google.com"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFile"); // This line is essential, or no cookie will be used in the next request, cookie location can also be left blank, do difference, just nothing gets saved into the specific file. Windows requires full path for cookiejar and cookiefile, tried that as well with no luck curl_exec($ch); curl_setopt($ch, CURLOPT_URL, "http://www.google.com/intl/et/privacy.html"); curl_exec($ch); ?> PHP: When sniffing packets with SmartSniff, there is a cookie used to access the second page GET / HTTP/1.1 Host: www.google.com Accept: */* GET /intl/et/privacy.html HTTP/1.1 Host: www.google.com Accept: */* Cookie: PREF=ID=1edfb9c4b15985cb:TM=1280146068:LM=1280146068:S=-mDZ6hBKftL11Gnf; NID=37=wqE5mbHz8iehHH2jC8xLMP1YFo6O5RWYNQRngkte4qAgTS9N3VvGtKLp6_iQe78qbbmP2_thnGhCAXFjid6C8yw5NY6M2L2NTtfZCQ7UJGNuSnQc9CifTjCx2xPNev2s Code (markup): Okay, quite a long post, but it would really be an interesting thing to figure out. Thanks for taking the time!
Okay, I guess I solved it by myself. It looks like, that the cookie filename can NOT be similar to the script filename, strange, huh? I'll give it a few more tests to see if it really is so.