Re: two php scripts with same $_SESSION variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jean-Christophe Roux wrote:
Hello,

Thank you for the answers. The issue is that the same codes are in folders A and B. When they are run from two different browsers, I am getting the behavior I 'd like to see with two session ids being created and therefore no sharing of $_SESSION variables.  But when the two apps are opened inside the same browser, the $_SESSION variables are shared and that makes sense because session_id() returns the same value. It would be be nice that when the app in A is running and the user starts the app in B, in the same browser widow, the server and php are instructed to realize that this is a brand new session and assign a new session_id() which would solve my problem. Is there  a way to achieve that?

Regards,




----- Original Message ----
From: Stut <stuttle@xxxxxxxxx>
To: Jean-Christophe Roux <jcxxr@xxxxxxxxx>
Cc: php-general@xxxxxxxxxxxxx
Sent: Thursday, May 24, 2007 7:34:24 AM
Subject: Re:  two php scripts with same $_SESSION variables

Jean-Christophe Roux wrote:
I have folder A with the following php script:
<?php
session_start();
$_SESSION['dummy']=10;
echo $_SESSION['dummy'];
?>
in folder B (same level as A), there is
<?php
session_start();
echo $_SESSION['dummy'];
?>
when running the script in B, in can see the value 10. How can I make sure that the $_SESSION['dummy'] is not shared between the two scripts? I could change the name but that would not be convenient.

You'll have to change the name. The whole point of sessions is to allow scripts to share variables between requests.

-Stut


So what your saying, is that.. you want a webpage open twice but with different session_id? The only way to do that would be to create a session_id yourself, eg. session_id(time().rand(0,1000)); Then pass that id through your scripts via POST or GET, start the session using that ID. You can then start as many sessions as you like.

Darren

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux