We help IT Professionals succeed at work.

Avoiding session collision between browser window instances

upandrun3 asked
Last Modified: 2013-12-13
Hi Experts,

I was wondering if anyone has come across the problem where users will open up multiple tabs or windows of your web application and then discover that parts of the application are using the other window/tab's data (I'm sure you have).

Obviously, this is occurring because the tabs/windows are sharing the same PHP session ID and so when you call up a record and store it's ID in the session, the second window's call replaces the ID of the first window and can cause all types of headaches.

What solutions have you come up with to avoid this problem?  Putting the ID in a hidden field?  Using session name rewriting at the top of your script (which I'd like to avoid)? I'm curious to the solutions you have come up with for this problem. Is my design junk and I shouldn't do it like that? How do the big players out there solve this problem?

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock this solution and get a sample of our free trial.
(No credit card required)


Hi Stormist and ThG,

Thanks for the comments.

what are the thoughts on the way I'm storing record data in the session?  Is there a better way to accomplish that then sessions, even over multiple calls of pages that use that record data?

Session variables are so flexible that you can come up with a system to fit your application. You could for instance, assign an unique ID each time data is submitted and group it with all the variables in the page that were submitted. You could utilize a database combined with a page id. To maintain the state of the page, you could as you mentioned above include a hidden id - this is how asp.net maintains the state for each page and avoids this problem.  


Hi Everyone, thanks for you comments.

I'm going to give the following ideas a try:

1.  using serialize with my wrapper class that I use in place of $_REQUEST to serialize data and sign it and pass that between page requests. This is along the same lines as the hidden ID on ASP.net.  

I'm gonna have to shelf this for a bit as other tasks require my attention. But I will come back and post a follow-up if I find a good solution to make the archives of EE more useful.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.