most likely you will need to initiate a new session using the new cookies in order to post to a second url after the sucessful login.
thats how i do it at least.
in the past to simplify gets and posts, ive wrapped curl into an easy function. maybe you can utilize it in a way...
function curl_post( $postUrl, $postData, $username, $referer = "http://www.site.com/default.phtml" )
{
global $headers;
$ch = curl_init($postUrl);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, USER_AGENT);
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_PATH . $username . ".txt");
curl_setopt($ch, CURLOPT_COOKEJAR, COOKIE_PATH . $username . ".txt");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
what i used for the $headers is
$headers[] = "Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg";
$headers[] = "Connection: Keep-Alive";
$headers[] = "Content-type: application/x-www-form-urlencoded";
basically call the function like this:
$output = curl_post("http://www.site.com/loginscript.php", "username=xxx&password=yyy&action=login", "myusername", "http://www.site.com/login.html");
obviously you can have as many curl_post's in one script as you like, either one after the other or spread around as needed.
the $username paramater i put in so i could have multiple users logged in at any given time, but you may be able to safely remove that.