Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.