On a tab with url http://foo.com/ I set a sessionStorage item thus-
sessionStorage.bar="hello";
I then open a new window on any path on the same domain -
window.open("http://foo.com/any/path");
Then on the new window I find that -
sessionStorage.bar === "hello"
Is true. The exact same thing happens if I use a link with target="_blank" attribute to open the new window. The exact same thing also happens when a new tab is opened, and not a new window. Another thing to note is that this is only true for items set on sessionStorage before opening the new window. Adding or changing any item on sessionStorage in either windows after the new window is opened does not effect the other window in any way.
I thought that sessionStorage was supposed to be scoped to a single tab/window, but apparently sessionStorage is extended to new tabs and windows when they are opened from another window.
Is there a way to prevent this? I can probably test for existence of window.opener to detect such a case, but it would be much cleaner if it was possible to prevent it in the first place.
Thanks!