I was trying to login to a site remotely. I have successfully done that and the landing page opens properly and i can extract all info fromo it. Problem is, when i click any link, the website logs me out! Earlier the link was relative to my domain, now ive changed it to the website domain but still the problem persists.. Im attaching the code for you to see how ive sent cookies.
I have executed another curl_exec to another url within the site, but the website logs me off!
<html>
<head>
<base href="http://site.net/" />
<body>
<?php
$username = $_POST["uname"];
$password = $_POST["pass"];
$fields = "username=" . $username . "&password=" . $password . "&Login.x=61&Login.y=15";
$ch=curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, 'http://www.amizone.net/amizone/default.aspx');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, "ASPSESSIONIDSQADDRBQ=OCALKIGABGLPCJLKMGIKJLLF");
curl_setopt($ch, CURLOPT_COOKIEFILE, "ASPSESSIONIDSQADDRBQ=OCALKIGABGLPCJLKMGIKJLLF");
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1000 );
curl_setopt($ch, CURLOPT_TIMEOUT, 10000 );
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8' );
curl_setopt($ch, CURLOPT_AUTOREFERER, 1 );
curl_setopt ($ch, CURLOPT_REFERER, "http://www.site.net/");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
ob_start();
$raw_data=curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, 'http:/site.net/amizone/WebForms/TimeTable/StudentTimeTableForWeek.aspx');
$ttable = curl_exec($ch);
ob_end_clean();
echo $ttable;
//curl_close($ch);
//$raw_data = preg_replace('/\s(1,)/',' ',$raw_data); //clean it up
//echo $raw_data;
//$raw_data = stripslashes($raw_data);
//$raw_data = explode("<strong>",$raw_data);
//2 3 and 4
//echo htmlentities($raw_data[4]);
?>
</body>
</html>
Note: I have taken the cookie name from 'LiveHttpHeaders', an extension for firefox.
What am i missing? Any help would be greatly appreciated!
Thanks in advance.