CodeIgniter Forums
Sessions + cURL = problem - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Sessions + cURL = problem (/showthread.php?tid=36905)

Sessions + cURL = problem - El Forum - 12-19-2010

why when I run from my sessions are created without problems in api subdomain, but if I run from a curl request through other domain these are ignored and not created?

I need that with my curl request in, create and save sessions in the same subdomain can someone help?

Sessions + cURL = problem - El Forum - 12-20-2010

$_SESSION['my_sess'] = 'some session value'; can run

And that's great !...the session it's ok, but try doing this

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/create_sess.php');
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$content = curl_exec($ch);

then...we got problems, the session is not set, why ?

Sessions + cURL = problem - El Forum - 12-20-2010


Sessions + cURL = problem - El Forum - 03-08-2011


I kind of have the same problem, how did you managed to do it ?

Sessions + cURL = problem - El Forum - 03-08-2011

Hi Abderrahmane, curl_exec($ch) create the sessions in the server, you can test returning the session value to see the result but curl_close($ch) "clean" everything in the server, then the sessions are destroyed, there's no way to store session with curl...

Sessions + cURL = problem - El Forum - 05-12-2012

[eluser]The Questioner[/eluser]
I've had this same problem and also wanted to know how you resolved it?

I have a script that sits outside CI and sends POST data to a specific CI controller using CURL.

The problem I’m having is that when the POST data is passed into my controller by CURL, all CI session variables are empty within the controller - but only during the CURL post. My controller relies on the cart session variable as well as other session variables (which were populated prior to the CURL call).

If I open another tab on my browser and call the same controller through via a URL, the session variables are back again.

How can I keep the session variables alive when the CURL POST is made?