blitz219 Posted December 30, 2009 Share Posted December 30, 2009 i have a problem logging into a remote website this code works to grab data from website but i want to be able to redicrect to the members section still logged in with a session id. <?php error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'www.remotesite.com/login.php'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); $user = 'username'; $pass = 'password'; // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, "login_username=$user&login_password=$pass"); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'www.remotesite.com/file.php'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); Link to comment https://forums.phpfreaks.com/topic/186727-remote-login-stay-logged-in/ Share on other sites More sharing options...
blitz219 Posted January 2, 2010 Author Share Posted January 2, 2010 anything? Link to comment https://forums.phpfreaks.com/topic/186727-remote-login-stay-logged-in/#findComment-986914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.