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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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