i want the value cookie that i got from the following code further used in php script to visit next url because value of cookie used in url ....how i can save value of cookie and again use it in my php script

suppose cookie is JSESSIONID GT1~A555400D38C7F737D383DEEBA8A30CE3.GT.1
and my next url is
http://www.url.com/q.action?id=A5554...BA8A30CE3.GT.1

<?php
$cookie=tempnam("/tmp","CURLCOOKIE");
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7";
;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $login);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $login);
$html=curl_exec($ch);

?>