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
There is a good example here,
http://sgjoomla.googlecode.com/svn/trunk/joomla/curltest.php
For some reason, the cookie part is commented out but all the code you need is still there.
Basically, you parse the "Set-Cookie" headers yourself and save the cookie value by doing this,
curl_setopt ($ch, CURLOPT_HEADERFUNCTION, 'read_header');
Put the cookie value in a global. In next call, set it like this,
curl_setopt($ch, CURLOPT_COOKIE, "$cookieName=$cookieValue");