hip_hop_x Posted August 29, 2008 Share Posted August 29, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/121792-curl-bot-doesnt-keep-the-session/ Share on other sites More sharing options...
JonnoTheDev Posted August 29, 2008 Share Posted August 29, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/121792-curl-bot-doesnt-keep-the-session/#findComment-628860 Share on other sites More sharing options...
hip_hop_x Posted August 31, 2008 Author Share Posted August 31, 2008 thanks, but still doesn't work, even when chmod to 777 the file cookies or using the tmp/cookie.txt... When i use load_page second time, asks for login, wich means that it didn't keep the page logged it. Quote Link to comment https://forums.phpfreaks.com/topic/121792-curl-bot-doesnt-keep-the-session/#findComment-630519 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.