View Single Post

 
Old 05-27-2008, 10:40 AM
HOND <b>Offline</b>
Junior Member
 
Join Date: May 2008
Posts: 1
hmm I am also just starting to loggin with cookies/curl.

I had a little bit similar problem as you had above.
I needed to log in monsterboard.nl ( ssl hiring ).

I did the following thing and it worked.

step 1:

Quote:
$LOGINURL = " Login url "
";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
$result = curl_exec ($ch);
curl_close ($ch);

step 2 : cookie is written

$LOGINURL = " Now do live http headers and get the same post sent page";
$POSTFIELDS = '$post data';
$reffer = "Same url as LOGIN url";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
$result = curl_exec ($ch);
curl_close ($ch);



This should do the job.
Reply With Quote