> -----Original Message-----
> From: Thijs Lensselink [mailto:d...@lenss.nl]
> Sent: Sunday, January 23, 2011 12:21 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Different sessions, same client
> 
> -----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?
> >
> > Paul
> >
> 
> 
> Using session_name will allow you to run two different sessions in the same
> browser.
> 
> session_name('app1');
> session_start();

Paul,

I'd would go with session_name($_SERVER['SCRIPT_NAME']) or 
session_name(substr($_SERVER['SCRIPT_NAME'], 0, 
strripos($_SERVER['SCRIPT_NAME'], '/')).  My regex skills sucks so I can't give 
you a sample using regex.  But you get the idea.

It's easier to get a particular app's relevant data to the URL while not hard 
coding the session name, eventually giving your app(s) more flexibility 
especially if you may have multiple URLs mapped to an app serving different 
purposes/clients.

Regards,
Tommy


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

Reply via email to