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

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

 



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/

--
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