Gruzin Posted November 9, 2008 Share Posted November 9, 2008 Hey, I'm trying to log in using cURL and I need to set the session, but the cookie.txt is always emty and session is nerver set. hope someone can help... here is my code: <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://localhost/parts/padmin/login.php'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user=gio&pass=gio'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HEADER, TRUE); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // CLOSE CURL curl_close ($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/132030-problem-with-setting-the-session-when-using-curl/ Share on other sites More sharing options...
Caesar Posted November 9, 2008 Share Posted November 9, 2008 If the folder the curl script is being executed from is not writable, change the cookie path to something like temp/cooki.txt, and make /temp CHMOD 777. Quote Link to comment https://forums.phpfreaks.com/topic/132030-problem-with-setting-the-session-when-using-curl/#findComment-686072 Share on other sites More sharing options...
Gruzin Posted November 9, 2008 Author Share Posted November 9, 2008 Thanks, but it's not working... Quote Link to comment https://forums.phpfreaks.com/topic/132030-problem-with-setting-the-session-when-using-curl/#findComment-686084 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.