RE: [PHP] Can several different sessions coexist?

From: Date: Thu, 01 Aug 2002 21:48:41 +0000
Subject: RE: [PHP] Can several different sessions coexist?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-110747@lists.php.net to get a copy of this message
> I'd like to register a session and create several session variables. In > another part of my site, I'd like to register another session again > creating > session variables. After a bit, I'd like to destroy this second > registered > session keeping the first intact. Thus far, whenever I issue: > > session_unset(); > session_destroy(); > > both sessions are obliterated. Is there a method of managing different > sessions where I can create additional sessions and destroy them without > losing my initial session? There is only one $_SESSION. What you can do, though, assuming you're using the latest version of PHP, is make $_SESSION a multi-dimensional array. So for one area of your site, you can assign variables to the session like this: $_SESSION['area_one']['value1'] = "This String"; $_SESSION['area_one']['value2'] = 10; Then, in another area, you can do the same thing, basically... $_SESSION['area_two']['value1'] = 'Something'; $_SESSION['area_two']['value2'] = 1000; Then...when you want to drop the session values for Area Two, you just do this: Unset($_SESSION['area_two']); ---John Holmes...

« previous php.general (#110747) next »