Neil Kimber wrote:
> We have an application framework that tidies up application session
> variables as you traverse from page to page. It works really nicely - until
> a user opens up 2 instances of a browser. Our code cannot distinguish
> between different browser instances, so browser instance 2 causes our
> application session vars for browser instance 1 to be cleared out.
> We've toyed with many ideas and short of forcing a unique hidden value to be
> 'POST'ed to every page from every page we don't have an elegant solution. Is
> there any other way that we could do this?
I'm not sure there is an elegant solution. Other alternatives are:
a) Pass the value as a a GET value or PATH_INFO on the urls. That at least
works with links as well.
b) Route your urls through a master script that picks up the value and then
"includes" the real pages.
c) Get your web-server to do an url rewrite from a url with the embedded id to
your scripts e.g. a rewrite from
http://www.mysite.com/rest_of_the_url, with id set as an environment variable.
I guess my favourite of these would be c), which is fairly easy with Apache and
mod_rewrite and saves you having to make any changes to your scripts. It also
means you don't have to change any urls which are relative to the current page,
but absolute urls are another matter. You would need to have set the id in the
first place somewhere, either by trapping when it's missing on a page, picking
it up and sending a location header with it included, or by getting the rewrite
to go off to a special script if it's missing
My very favourite solution is not to use sessions. They've always struck me as
"swimming against the tide" i.e. trying to impose state on fundamentally
state-less protocols. But then I never believed in client-server, which is what
sessions seem to be about fudging...
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php