According to mozilla.org :
The session cookie [...] is deleted when the client shuts down because it did not specify the Expires or Max-Age directive. However, web browsers can use session recovery , which makes most session cookies persistent, as if the browser never closed.
According to function documentationcurl_setopt :
By default, libcurl always stores and loads all cookies, regardless of whether they are session files or not. Cookie session cookies are cookies without an expiration date and they must be alive and existing for this session "only.
If you save the cookie in the specified file with
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://stackoverflow.com');
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
$output = curl_exec($ch);
curl_close($ch);
, , , CURLOPT_COOKIEJAR cookie. script.