views:

38

answers:

1

Is there an accepted pattern for tracking that a page is being loaded by the same tab/window?

There are certain processes (like stepped submission processes), which can greatly benefit from a ability to verify that the same tab is asking for execution.

For example, there are places where (between steps) we store intermediate data in memcache, but this can cause a problem without the ability to scope that data to this process, as opposed to if the user opens another tab/window on the same process.

This holds true for many actions/processes.

Some brainstorming has not come up with anything dependable.

Ideas anyone?

+1  A: 

You could maintaining the state of a multi-step process using query parameters (if you use GET requests) or hidden fields (if you use POST requests) or both (if you POST-then-redirect, to allow the user to refresh her browser).

If you maintain state on the server (e.g. in a DB or memcached) you could just keep a "transaction key" in a query parameter or hidden field.

Be wary, though - in my experience, it's possible to design such a stateful multi-stage process fairly cleanly, but it may be tricky to implement and to maintain a non-surprising user experience. For example, what happens when you move back and forth between the stages? You could allow this explicitly, or the user could use the back button, but the process should still make sense.

EDIT:

As a concrete example:

  1. User clicks "Start multi-step process", which does a POST to the server
  2. Server then
    • initializes state for a process
    • gives it unique key "A"
    • keeps it in a temporary store (e.g. memcached)
    • redirects the user to "/process/A/step/1"
  3. The next step for the process would be "/process/A/step/2"
  4. User, in a different tab, clicks "Start multi-step process" again
  5. Server does the same but
    • uses a unique key "B"
    • redirects to "/process/B/step/1"
  6. The next step for this second process would be "/process/B/step/2"
  7. The two processes now have independent server-side state
orip
This would still not guard against copy/pasting URIs between windows. However, that would be something which may be acceptable risk. If it could be detected, you could at least warn the user. The browser exposing a unique tab id to the window object would be nice. :) Thanks for the comment.
Spot