Log in is ok but when trying to then move to another https page I find that I am rejected and need to log in again. If anyone can help, Thanks.
$cookie = "cookies/test";
@unlink($cookie);
$data="";
$ch=curl_init('https://www.secure.asp');
if (!$ch){
die(sprintf('Error [%d]: %s',curl_errno($ch),curl_error($ch)));
}
$id="myid";
$pass="pass";
$submit="USERID=$id&password=$pass";
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$submit);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_HEADER,1);
$data=curl_exec($ch);
if (!$data){
die(sprintf('Error [%d]: %s',curl_errno($ch),curl_error($ch)));
}
curl_close($ch);
//echo $data;
//exit;
//////////////// if I drop out here I am logged in and cookie has been set.
//unset($ch);
?>
<?php // second stage
$data="";
$ch=curl_init('https://www.secure/another_page.asp');
if (!$ch){
die(sprintf('Error [%d]: %s',curl_errno($ch),curl_error($ch)));
}
$quantity1=1;
$i=0;
$stuff[$i]="book-01";
$quantity1=1;
$submit=""
."Code1=".$stuff[$i]
."&quantity1=".$quantity1
."&Source=FastOrder&submit1.x=0&submit1.y=0";
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$submit);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt ($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_HEADER,1);
$data=curl_exec($ch);
if (!$data){
die(sprintf('Error [%d]: %s',curl_errno($ch),curl_error($ch)));
}
curl_close($ch);
echo $data;
Thanks