Jump to content

Curl bot - doesn't keep the session


hip_hop_x

Recommended Posts

Hello! I'm working at a bot to log in from the login page using my username and password, the problem i'm having is that it doesn't stay logged, and i need it to stay active so it can view a page that is only accesible to users.

 

function load_page($url,$parameters=""){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
if($parameters!=""){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
}
curl_setopt($ch, CURLOPT_URL,$url);
$web=curl_exec($ch);
curl_close ($ch);
return $web;
}
$data="username=hip_hop_x&password=pass_changed&redirect=1";
echo load_page("http://www.warez-bb.org/login.php",$data);
echo load_page("http://www.warez-bb.org/viewtopic.php?t=1544880");

Any suggestion is welcome, and if you can give me an example too it would be even better. Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/121792-curl-bot-doesnt-keep-the-session/
Share on other sites

The cookie needs to be stored in a directory that can be written to. You dont seem to have supplied a path i.e.

 

curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");

 

So no cookie, no login!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.