Session Variables and multiple tabs
Posted: Mon Jan 18, 2010 8:20 am
We've got several incarnations at various clients of a bespoke ecommerce site using Session Variables to hold the cart details and other details.
We've become aware of a problem when the user clones their web browser window either into a new tab or a complete new process.
Although there are now 2 (or more) web pages displaying on their PC, there is still only 1 session shared between them.
So if the user uses webpage A to order stuff, then suddenly switches to the other window for some reason, then switches back (and yes some people have done that), then to the PHP script processing the submitted data there can appear to be corruption in the session variables.
In fact it's not corruption, it's the result of a change on the other window, which is perfectly valid in itself, but appears like corruption to the other webpage.
Does anyone have a recommended way of dealing with this?
- Hold all cart info etc in hidden fields on the web page?
- hold session variables as arrays, a row per webpage. Then try to spot when a new window is created, and assign a new row in the session array variable?
Cheers - Malcolm
We've become aware of a problem when the user clones their web browser window either into a new tab or a complete new process.
Although there are now 2 (or more) web pages displaying on their PC, there is still only 1 session shared between them.
So if the user uses webpage A to order stuff, then suddenly switches to the other window for some reason, then switches back (and yes some people have done that), then to the PHP script processing the submitted data there can appear to be corruption in the session variables.
In fact it's not corruption, it's the result of a change on the other window, which is perfectly valid in itself, but appears like corruption to the other webpage.
Does anyone have a recommended way of dealing with this?
- Hold all cart info etc in hidden fields on the web page?
- hold session variables as arrays, a row per webpage. Then try to spot when a new window is created, and assign a new row in the session array variable?
Cheers - Malcolm