troubleshooting Question

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

Avatar of Sailo100
Sailo100 asked on
PHP
3 Comments1 Solution733 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros