Re: Multiple sessions open at same time, is it possible?

From: Date: Sun, 02 Mar 2008 14:57:34 +0000
Subject: Re: Multiple sessions open at same time, is it possible?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-270830@lists.php.net to get a copy of this message
On 2 Mar 2008, at 14:49, Richard wrote:
I'm quite new to sessions, an am trying to program a script which needs two sessions ... I have a members area which uses 1 session, and when you click on disconnect it closes the session and the user returns to the login page. I also am programming a shopping cart so members can choose what they would like to download that also uses a session. All worked fine untill I realised that because they both use the same session, when I disconnect from the members area it also obviously deletes all elements from the download cart. I would there for need to have two seperate sessions one for the cart, and one for the members area. And sometimes I will need to have them both open. Is this possible ? I've searched google but not found anything interesting, except session_name, but I still don't know how to open two sessions or close one session but not the other, or open a variable in a specific session ...
Just use one session. Put the data for each session into a separate array... $_SESSION['members'] = array('lots', 'of', 'data'); $_SESSION['cart'] = array('lots', 'of', 'money-making', 'crap'); To "disconnect" the user from one or other simply unset that variable... unset($_SESSION['members']); unset($_SESSION['cart']); KISS. -Stut -- http://stut.net/

« previous php.general (#270830) next »