I couldn't access the cookie file after curl_close() although it's created successfully (not a file path issue). So, I added a 15 seconds of sleep after curl_close() and I noticed that the cookie file is created only after the 15 seconds, i.e. after the whole php file ends.
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
$response = curl_exec($ch);
curl_close($ch);
//I can't find the cookie file here
sleep(15);
CodePudding user response:
According to this:
The name of a file to save all internal cookies to when the handle is closed, e.g. after a call to curl_close.
The file is saved when curl_close is called or when the class is destructed.