Re: [PHP] two php scripts with same $_SESSION variables



Jean-Christophe Roux wrote:
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?

It's frickin' annoying!
Why?
Please don't top post!

What you're wanting to do can be achieved by setting the path on the session cookies. You may be able to do this by calling ini_set to change session.cookie_path before calling session_start.

-Stut

----- 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: [PHP] 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

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



------------------------------------------------------------------------
Get your own web address. <http://us.rd.yahoo.com/evt=49678/*http://smallbusiness.yahoo.com/domains/?p=BESTDEAL>
Have a HUGE year through Yahoo! Small Business. < http://us.rd.yahoo.com/evt=49678/*http://smallbusiness.yahoo.com/domains/?p=BESTDEAL>
.



Relevant Pages

  • Re: Looking for general advice on security
    ... PHP pages have to be world-readable, ... SSL provides a way for a thief with a browser to communicate with ... cookies because the user can't fake a session with arbitrary contents, ... Try to send a message to the user and see if the mail server ...
    (comp.lang.php)
  • Re: setting session timeout through .htaccess
    ... >In all of my sessions work with PHP the ... >session identifier cookie is set automatically by PHP with an expiry ... >time of the life of the browser... ... their cookie is alive... ...
    (comp.lang.php)
  • Re: [PHP] error messages
    ... on the browser. ... Even if you place the lines at the top of scripts as others have suggested, it will not fix your issue if your script has a parse error in it. ... This is because PHP pre-parses each script. ... My suggestion is to use modify the php.ini file directly and change the values that the others have suggested or, if you're using Apache, use a .htaccess file with the values set to forcephp to display errors. ...
    (php.general)
  • Re: how to get object in pages !!!
    ... > functions of java from my php page. ... same operation with $_SESSION also is not ... Try these two scripts to see if sessions are working: ...
    (comp.lang.php)
  • RE: [PHP] PHP $_SESSION Expiring in IE
    ... "Do you have pages that detect the browser and feed alternate content ... [PHP] PHP $_SESSION Expiring in IE ... something with that affect that IE might be handling in a wierd way? ...
    (php.general)