Jump to content

Session with cURL


phpFavs

Recommended Posts

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].";");

 

 

Link to comment
https://forums.phpfreaks.com/topic/235533-session-with-curl/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/235533-session-with-curl/#findComment-1210740
Share on other sites

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');

Link to comment
https://forums.phpfreaks.com/topic/235533-session-with-curl/#findComment-1210756
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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