0

I need a way of being able to do the following:

A web application has a variable called 'setting'.

When a user first connects to the application, setting should have a value of 'default'.

Setting can be changed in any page.

If a user middle-clicks to open a page in a new tab, that page's setting should be a copy of the current page's setting (a copy, not a reference to it).

If a user opens a new tab and types in the web app's URL, then that page's value of setting should be 'default'.

If a user left clicks a link, then the new page should have the same value for setting as the referring page (the same value, not a copy).

Implementation:

I can obviously do this with a nasty url hack (...?setting=foo), but this gets nasty when there are many settings.

Is there any 'per-tab' storage available on browsers.

Theory:

The theoretical underpinning for this behaviour is the concept of a subsession. All subsessions belong to the session. Subsessions have a parent, if their tab was opened by a middle click. If their page loaded by typing a URL in an empty tab, then the subsession has no parent. Settings can be stored in subsessions, and is a setting is not present in a subsession, the parent's value is used instead.

Has anyone got any ideas on how to do this nicely?

Are there any sites which already behave this way?

Thanks,

Chris.

fadedbee
  • 42,671
  • 44
  • 178
  • 308
  • http://groups.google.com/group/firebug/browse_thread/thread/42daac35c0da63eb/82daa8f699733c7b – fadedbee Jun 10 '11 at 15:38
  • "_but this gets nasty when there are many settings_" nasty how? length of URL? – curiousguy Jul 07 '12 at 02:21
  • Possible duplicate of [How to differ sessions in browser-tabs?](http://stackoverflow.com/questions/368653/how-to-differ-sessions-in-browser-tabs) – guettli Dec 09 '15 at 11:49

2 Answers2

2

I think this would work for you: http://www.xul.fr/en/html5/sessionstorage.php

eirc
  • 1,654
  • 14
  • 14
  • See [http://stackoverflow.com/questions/20325763/browser-sessionstorage-share-between-tabs](http://stackoverflow.com/questions/20325763/browser-sessionstorage-share-between-tabs) – honzajde Sep 02 '15 at 14:04
0

I have written a solution to this issue at:

https://github.com/chrisdew/subsession

It is obviously in early development and may contain bugs.

fadedbee
  • 42,671
  • 44
  • 178
  • 308