curl-and-php
Re: PHP + cURL + session id
Date: Thu, 27 Apr 2006 00:24:56 +0200
Thans for your reply.
You suggest to call session_id($sess_id) before session_start(), right? I
tried that and did not work. Actually, I send $sess_id as a GET arg and in
the third script I called those two functions mentioned abowe.
If you have any other suggestions let me know.
Luke
2006/4/26, Sudeep Agarwal <agarwalsudeep_at_gmail.com>:
>
> in order to use the same session u need to a session identifier ie
> "PHPSESSID" in ur case. Whenever a session started a cookie named PHPSESSID
> will be generated which will have a session id so u need to use the session
> id value in the third page to continue with same session.
>
> So in first script t1.php save the session id using
> $sess_id = $_SESSION['PHPSESSID'];
>
> pass this $sess_id in session_start() in the third script
>
> On 4/26/06, lookee24 <lookee24_at_gmail.com> wrote:
>
> > Hello all,
> I have simple PHP application that on one page strarts session and
> write some information to it. On another page program tryes to fetch
> information from a third page using cURL. On that third page program
> needs to retrive information that were written to the session and use
> them. Problem is that when I call the third page and call
> session_start() it starts a new session where there are no infromation
> I need. Code below.
>
> <code>
> <?
> /**
> * file: t1.php
> */
> session_start();
> $_SESSION['user'] = 'lukas';
> echo '<html>
> <body>
> '.$_SESSION['user'].' 2 >>
> </body>
> </html>';
> ?>
>
> <?
> /**
> * file: t2.php
> */
> session_start();
> $_SESSION['user'].=" add some info.";
> $url=" http://www.myserver.com/t3.php<http://www.google.com/url?sa=D&q=http://www.myserver.com/t3.php>"
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, $url);
> curl_setopt($ch, CURLOPT_TIMEOUT, 2);
>
> //when I uncomment that line operation times out
>
> //curl_setopt($ch, CURLOPT_COOKIE, session_name()."=".session_id().";");
> $output = curl_exec($ch);
> echo "output: ".$output."<br/>";
> echo "error no: ".curl_errno($ch)."<br/>";
> echo "error: ".curl_error($ch)."<br/>";
> curl_close($ch);
> ?>
>
> <?
> /**
> * file: t3.php
> */
> session_start();
> if(isset($_SESSION['user']))
> echo "yeah<br/>";
> else
> echo "nope<br/>";
> ?>
> </code>
>
> My PHP Version 4.4.2-1
>
> My php.ini session settings:
> Session Support enabled
> Registered save handlers files user
> session.auto_start Off Off
> session.bug_compat_42 On On
> session.bug_compat_warn On On
> session.cache_expire 180 180
> session.cache_limiter nocache nocache
> session.cookie_domain no value no value
> session.cookie_lifetime 0 0
> session.cookie_path / /
> session.cookie_secure Off Off
> session.entropy_file no value no value
> session.entropy_length 0 0
> session.gc_divisor 100 100
> session.gc_maxlifetime 1440 1440
> session.gc_probability 0 0
> session.name PHPSESSID PHPSESSID
> session.referer_check no value no value
> session.save_handler files files
> session.save_path /var/lib/php4 /var/lib/php4
> session.serialize_handler php php
> session.use_cookies On On
> session.use_only_cookies Off Off
> session.use_trans_sid Off Off
>
> My php.ini cURL settings
> CURL support enabled
> CURL Information libcurl/7.15.3 OpenSSL/0.9.8a zlib/1.2.1.1
> libidn/0.5.18
>
> Any help would be appreciated.
> Kind regards,
> Luke
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-04-27