Retrieving response with cookie with curl
<p>I am trying to check if a cookie exists on a server with a specific url.</p>

<pre><code>    $ch=curl_init();
//curl_setopt ($ch, CURLOPT_COOKIE, "mm=38533;" );
curl_setopt($ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEFILE,'/tmp/cookies.txt');
curl_setopt($ch,CURLOPT_URL,'http://www.engageya.com');
curl_setopt($ch, CURLOPT_HEADER, 1);
$response=curl_exec($ch);
// get cookie
preg_match('/^Set-Cookie:\s*([^;]*)/mi', $response, $m);

curl_close($ch);

var_dump(parse_url($m[1]));
echo "&lt;br/&gt;".$response;
</code></pre>

<p>The problem is when I am logged in onto the target site, and I need to check if I am logged into the site, so I try to retrieve the cookie from the site..But i fail.
I thought to use the curlopt_cookie option..but I thought if there is an easy way to return the cookie from the server and check if it exists .</p>

<p>In short the cookie exists when I surf to the page. But it doesnt exist when the request comes back and i print it</p>
