tags:

views:

25

answers:

3

I mean you can login both https://mail.google.com/ and https://mail.google.com/a/company.com at the same time.

The projects I've attended so far haven't involved such kind of logic,how can these two url under the same domain use different $_SESSION?

A: 

Those two URLs share the same domain. Only the subfolders are different. Usually with PHP, the cookie which saves the session id is valid for the whole domain and not only a specific subfolder. So there should be no problem using the session data with the same domain.

Kau-Boy
A: 

I think there is not inbuilt session management feature in PHP. You can use variable specific management in session. for eg. one login from https://mail.google.com/ then store all it's session data in $_SESSION['gmail'][X] , $_SESSION['gmail'][Y],$_SESSION['gmail'][Z]

and then in when another user login from https://mail.google.cpm/a/company.com then store all it's session data in $_SESSION['company'][X],$_SESSION['company'][Y],$_SESSION['company'][Z]

so by this, you can separate those two sessions from each other.

Maulik Vora
A: 

Maulik Vora's answer will work, but another way to do it is to configure PHP to used URL-based session ID passing. That way every tab or window has a separate session. See this page for information on how to do it, and why you may or may not want to. Here's the docs for it.

dj_segfault