learn

different sessions in the same site

category: Ask
Created by: Dr.Ferrous

different sessions in the same site

category: Ask
Created by: Dr.Ferrous
twitter google+ facebook pin 

Question

Hi. How I can allow different sessions in the same site using other browser tabs.

Thanks you.

by Felipe

Answer

Sessions are maintained in the server, and the only connection between the current session & the browser is the session id which is saved in cookies.

 

 

So, if you opened the same web page in another tab, it will use the same session because it's the same cookie value.

But, you can do a trick to create two sessions or even more for each browser tab, which is using predefined session IDs and additional cookie values.

 Example:

 

 

When you open the page for the first time, we will create our 2 sessions and save their IDs in cookies (session-1 & session-2).

And will use the first session as our default session.

If you opened the same page in another tab and with a query "UseSession", you'll be switched to the other session. Example:

http://www.domain.com/index.php?UseSession=1 // or without the query, will use the first session

http://www.domain.com/index.php?UseSession=2 // will use the second session

 

You can use another way to automatically switch between sessions. Example:

http://www.domain.com/AdminAccount/index.php

http://www.domain.com/UserAccount/index.php

And instead of using this script to distinguish between sessions:

 

 

use this: