phpFavs Posted May 4, 2011 Share Posted May 4, 2011 Hi, I am having trouble with my cURL call because when I run the exec method I loose my current login state in the session. I have tried the two options below, but they have yet to succeed. If there is anything else you want me to tell you that will help you understand my issue, please let me know. $sessionfile = fopen("sessionfile.txt", "w"); fputs($sessionfile, session_encode( ) ); fclose($sessionfile); $c->setopt(CURLOPT_COOKIEFILE, $sessionfile); $c->setopt(CURLOPT_COOKIEJAR, $sessionfile); $sessName = session_name(); $_COOKIE[$sessName] = session_id(); $_COOKIE['aud_logged_in'] = Session::isLoggedIn(); session_write_close(); $c->setopt(CURLOPT_COOKIE, $sessName."=".$_COOKIE[$sessName].";"); Quote Link to comment https://forums.phpfreaks.com/topic/235533-session-with-curl/ Share on other sites More sharing options...
btherl Posted May 5, 2011 Share Posted May 5, 2011 Do you want to make a curl request back to your own webserver, and use the same session in that curl request? Quote Link to comment https://forums.phpfreaks.com/topic/235533-session-with-curl/#findComment-1210709 Share on other sites More sharing options...
vicodin Posted May 5, 2011 Share Posted May 5, 2011 Just a note with sessions... I have notice with PHP sessions cant go between sub domains... So like lets say you login to http://www.mysite.com/home.php and lets say the person who made the site made their home link to http://mysite.com/home.php the session will be lost. So maybe you logged into www.mysite.com but are trying to connect in cURL to mysite.com, I could see the session being lost like that. Quote Link to comment https://forums.phpfreaks.com/topic/235533-session-with-curl/#findComment-1210740 Share on other sites More sharing options...
phpSensei Posted May 5, 2011 Share Posted May 5, 2011 Just a note with sessions... I have notice with PHP sessions cant go between sub domains... So like lets say you login to http://www.mysite.com/home.php and lets say the person who made the site made their home link to http://mysite.com/home.php the session will be lost. So maybe you logged into www.mysite.com but are trying to connect in cURL to mysite.com, I could see the session being lost like that. You can always do ini_set (' session.cookie_domain', 'yoursite.com'); Quote Link to comment https://forums.phpfreaks.com/topic/235533-session-with-curl/#findComment-1210756 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.