Page 1 of 1

Handling Browser Tabs

Posted: Wed Nov 15, 2006 6:37 am
by CoderGoblin
Hopefully this comes under advanced topics, if not please move it mods...

Imagine the scenario, you have a "register wizard" containing multiple forms in separate html pages. When the user cancels any page they go back to the page they started from (as though the widget was a singlepage). Normally I would store the original page in a session variable or have a history session array and use

Code: Select all

history("Location: {$_SESSION['back_page']}"); exit;
to redirect.
For the sake of argument on the site you also have several other "wizards" doing the different things, often from a generic menu.

This works fine in a non-tabbed browser environment, but when the user as access to "open link in new browser" you cannot just store a single session variable of where to go back to.

The Design Question I would like to pose consists simply of how to store this information and redirect the user in a meaningful manner.

Possible solution I can think of...

a) Each "wizard" has a separate session variable holding the page it came from. Unfortunately this doesn't work as what happens when the same wizard is opened multiple times from different locations/tabs ?
b) Use Javascript to question the browser history... OK I think but for the sake of argument, javascript is disabled.

Questions:
1) Can anyone else think of other solutions ?
2) Can anyone else think of any other considerations we need to think of during design/coding for users with browser tabs available?

Regards

Posted: Wed Nov 15, 2006 10:53 am
by johno
Have you heard about Continuations? http://en.wikipedia.org/wiki/Continuati ... tinuations

Posted: Wed Nov 15, 2006 11:32 am
by obiron
I'm coming across exactly the same problem (I think).

I am asking users to log in and then keep track of where they are in the application without using cookies or sessions. I've made the choice to do the whole damn thing in Ajax so the system is stateless. A refresh command kills the system becuase it goes back to the page submission after the log in form.

so......

I am generating a 'random' session id as part of the log in form and storing that server side in a database.

Every Ajax page request triggers an update of where the user is in the application (becuase its ajax, the $_POST values are not updated).

If a user hits back, then they are taken back to the log in page. If a user hits refresh or forwards into the post logged in page then the PHP is intercepting the fact that the session ID is in the $_POST, looks it up in the database and calls the right php page/function to inject the html into the already generated page.

If the user starts a new browser window then they have to log in again, unless they are using something like Slimbrowser which allows you to duplicate a tab and copies it including the headers......



Using Ajax means that I can now never use the submit button on the form, I will always have to post the results as part of a url, and insert them into the database as part of the PHP script.