Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8100 > unrolled thread

cURL and $_SESSION

Started bybill <william@TechServSys.com>
First post2013-01-20 12:17 -0500
Last post2013-01-20 12:25 -0500
Articles 5 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  cURL and $_SESSION bill <william@TechServSys.com> - 2013-01-20 12:17 -0500
    Re: cURL and $_SESSION bill <william@TechServSys.com> - 2013-01-20 12:22 -0500
      Re: cURL and $_SESSION Richard Yates <richard@yatesguitar.com> - 2013-01-20 09:30 -0800
        Re: cURL and $_SESSION bill <william@TechServSys.com> - 2013-01-20 13:53 -0500
    Re: cURL and $_SESSION bill <william@TechServSys.com> - 2013-01-20 12:25 -0500

#8100 — cURL and $_SESSION

Frombill <william@TechServSys.com>
Date2013-01-20 12:17 -0500
SubjectcURL and $_SESSION
Message-ID<kdh8qq$u4k$1@speranza.aioe.org>
I am invoking a script via cURL, with POST variables.  Seems to 
work fine, but...

On the first invocation I set a session variable, when I return 
to the same script via cURL from the same computer (with a 
different command) the session array is empty.

I verified that I am setting the session variable correctly.

What is special about using Session when invoking a script via cURL

-bill

[toc] | [next] | [standalone]


#8101

Frombill <william@TechServSys.com>
Date2013-01-20 12:22 -0500
Message-ID<kdh947$uqf$1@speranza.aioe.org>
In reply to#8100
On 1/20/2013 12:17 PM, bill wrote:
> I am invoking a script via cURL, with POST variables.  Seems to
> work fine, but...
>
> On the first invocation I set a session variable, when I return
> to the same script via cURL from the same computer (with a
> different command) the session array is empty.
>
> I verified that I am setting the session variable correctly.
>
> What is special about using Session when invoking a script via cURL
>
> -bill

yes, I do session_start (); as the first executable line in the 
script.

-bill

[toc] | [prev] | [next] | [standalone]


#8103

FromRichard Yates <richard@yatesguitar.com>
Date2013-01-20 09:30 -0800
Message-ID<4daof8tqhoam7jg75aiarj1s6n4uk03h3g@4ax.com>
In reply to#8101
On Sun, 20 Jan 2013 12:22:25 -0500, bill <william@TechServSys.com>
wrote:

>On 1/20/2013 12:17 PM, bill wrote:
>> I am invoking a script via cURL, with POST variables.  Seems to
>> work fine, but...
>>
>> On the first invocation I set a session variable, when I return
>> to the same script via cURL from the same computer (with a
>> different command) the session array is empty.
>>
>> I verified that I am setting the session variable correctly.
>>
>> What is special about using Session when invoking a script via cURL
>>
>> -bill
>
>yes, I do session_start (); as the first executable line in the 
>script.
>
>-bill

This looks like the solution: 

http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/

[toc] | [prev] | [next] | [standalone]


#8104

Frombill <william@TechServSys.com>
Date2013-01-20 13:53 -0500
Message-ID<kdhefo$dlt$1@speranza.aioe.org>
In reply to#8103
On 1/20/2013 12:30 PM, Richard Yates wrote:
> On Sun, 20 Jan 2013 12:22:25 -0500, bill <william@TechServSys.com>
> wrote:
>
>> On 1/20/2013 12:17 PM, bill wrote:
>>> I am invoking a script via cURL, with POST variables.  Seems to
>>> work fine, but...
>>>
>>> On the first invocation I set a session variable, when I return
>>> to the same script via cURL from the same computer (with a
>>> different command) the session array is empty.
>>>
>>> I verified that I am setting the session variable correctly.
>>>
>>> What is special about using Session when invoking a script via cURL
>>>
>>> -bill
>>
>> yes, I do session_start (); as the first executable line in the
>> script.
>>
>> -bill
>
> This looks like the solution:
>
> http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/
>

That did not do the job, but gave me a hint.
I fixed the problem by adding:
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
so that curl would know where to save the SESSION Cookie and 
where to find it for the next script.

-bill

[toc] | [prev] | [next] | [standalone]


#8102

Frombill <william@TechServSys.com>
Date2013-01-20 12:25 -0500
Message-ID<kdh99q$uqf$2@speranza.aioe.org>
In reply to#8100
On 1/20/2013 12:17 PM, bill wrote:
> I am invoking a script via cURL, with POST variables.  Seems to
> work fine, but...
>
> On the first invocation I set a session variable, when I return
> to the same script via cURL from the same computer (with a
> different command) the session array is empty.
>
> I verified that I am setting the session variable correctly.
>
> What is special about using Session when invoking a script via cURL
>
> -bill

I have other scripts on that server that use $_SESSION and are 
invoked from the web - Session works just fine.

-bill

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web