Re: Different sessions, same client
| From: | tedd | Date: | Sun, 23 Jan 2011 16:45:30 +0000 |
| Subject: | Re: Different sessions, same client | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310982@lists.php.net to get a copy of this message | ||
At 11:02 AM +0000 1/23/11, Ashley Sheridan wrote:
On Sun, 2011-01-23 at 09:21 +0100, Thijs Lensselink wrote:Paul: Ash's method is a good one. You might also consider using uniqid() to create a unique ID for your users and then use that ID for determining which user is which instead of using username. Cheers, tedd -- ------- http://sperling.com/-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/23/2011 07:33 AM, Paul M Foster wrote:Storing any sort of login/auth data in cookies has regularly been panned on this list. The preference seems to be to store whatever login/auth information *must* be stored in the $_SESSION variable. Well and good. My problem, however, is that I have multiple applications in different tabs running on the same server, which may all use the same sub-variables, like "username". As a result, they run into each other. One application will think I'm logged in when I'm not logged in to that application, but to another in the same browser on the same box. So my question is how to prevent this using the standard PHP functions relating to sessions. I'd like different applications in different tabs on the same box/browser to have different sessions, so they don't share data. Thoughts?PaulYou can of course use arrays in your session as well: $_SESSION['app_name'] = Array('username' => 'John', 'user_id' => 1234, 'some other info' => 'another string',); I use this on my localhost sometimes, as it can be easier running tests and stuff than having to create a whole new host entry for it in my config files! Thanks, Ash