Welcome Guest, Not a member yet? Register   Sign In
Sessions + cURL = problem

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

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

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

the...you 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 ?



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

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

[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?

Theme © iAndrew 2016 - Forum software by © MyBB