Link to home
Start Free TrialLog in
Avatar of Sailo100
Sailo100

asked on

What is the best way to handle session variables and multiple browser tabs

I have spent the last 2 years working on an extremely large project that i have written from the ground up (except for the odd third party script here and there)

I have designed the system in such a way that everything runs via index.php and depending on what module you pass as a parameter it includes the relevant php file with that modules code for listing, forms, queries etc.

I am basically self taught and have not used any frameworks so I am positive that the way in which I am doing things is not the most elegant method but the system works and does not suffer with any speed issues.

The problem I have been experiencing for some time is if users load the site in multiple tabs within the same browser (sharing the session) and browse to different parts of my site.

I have some general functions for handling pagination, sorts, searches etc. which use standard session variables such as search, page, order etc. etc.

When the user browses from one module to another the system detects that the module has changed and therefore clears any old session variables relating to that module so to prevent an mysql errors occurring.

As you can see the problem here is that when you browse in tab 1 of you browser it clears out the session variables that were possibly needed for tab 2.

Please can anyone provide me with some advice on how to overcome this?

1. Can i prevent a user from logging into my system with tab2 in the browser?
2. Should i just re-write my shared functions so that they do not share session variable names?  If so how do I go about doing this?  Somebody mention a 3 dimensional array?
3. Should i look at a framework in order to get around this?

Any advice is helpful.
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sailo100
Sailo100

ASKER

Is it possible to detect what tab a user is using and pass this back to php?
AFAIK not. tabs are like windows from the perspective of Javascript.