I access a REST api service that utilizes a variable called session_id. The API calls for this to be stored in a cookie and I accomplish this as follows:
$ch
I use tempnam to generate a unique file name.
$ckfile = tempnam ("/tmp", "cookieMyWeb"); curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
Generate a new file name before using curl.