cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: How do I keep the $_SESSION info when I curl?

From: Stephen Pynenburg <spynenburg_at_gmail.com>
Date: Tue, 5 May 2009 07:57:50 -0400

Session_start() also has to be called from the second page you're requesting
(test2.php).
-Stephen

On Mon, May 4, 2009 at 22:12, Edward E. Murphy <ted_at_speak-tome.com> wrote:

> Yes, session_start() is called within init.php.
>
>
>
> Ted
>
>
>
>
> ------------------------------
>
> *From:* Stephen Pynenburg [mailto:spynenburg_at_gmail.com]
> *Sent:* Monday, May 04, 2009 8:50 PM
> *To:* ted_at_tedmurph.com; curl with PHP
> *Subject:* Re: How do I keep the $_SESSION info when I curl?
>
>
>
> Just to ensure the PHP side is correct, if you want PHP to resume a session
> from cookies in the request, you need to call session_start() at the
> beginning of that script.
> -Stephen
>
> On Mon, May 4, 2009 at 20:12, Edward E. Murphy <ted_at_speak-tome.com> wrote:
>
> Hello all,
>
>
>
> I have searched for this to no avail, please help.
>
>
>
> I want to use cURL to redirect from one file to another. The redirect
> works fine, but I am losing the $_SESSION information. How do I keep that
> info?
>
>
>
> Here is what I am using now (doesn’t work). The COOKIEJAR file at
> "/tmp/myCurlCookie.txt" is being created, but the $_SESSION info is still
> lost:
>
>
>
> <?php
>
> // fileurl is http://www.live-answers.com/test1php
>
>
>
> // this sets a bunch of $_SESSION cookie info
>
> require_once 'init.php';
>
>
>
> // use curl to redirect the url
>
> function useCurl($URL)
>
> {
>
> $ch = curl_init();
>
> curl_setopt($ch, CURLOPT_URL,"$URL");
>
> curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/myCurlCookie.txt" );
>
> curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/myCurlCookie.txt");
>
> curl_exec ($ch);
>
> curl_close ($ch);
>
> }
>
>
>
> // this calls the second test file, where the $_SESSION info is not
> available
>
> $URL="http://www.live-answers.com/test2.php";
>
> useCurl($URL);
>
> exit;
>
>
>
> ?>
>
>
>
> Best regards,
>
>
>
> Ted
>
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-05-05