different sessions in the same site
Created by: Dr.Ferrous
Hi. How I can allow different sessions in the same site using other browser tabs.
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.
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:
And instead of using this script to distinguish between sessions: