Re:Race conditions on the web
by throwawayReply on Wednesday July 13, 2016 @03:57AM
(#12084599)
SessionStorage has all of those properties:
https://developer.mozilla.org/en/docs/Web/API/Window/session...
localStorage is often used for it's persistance across closing/reopening the browser, but for times when you don't want storage to bleed across tabs or closing the browser then session storage is much better, and unlike a cookie doesn't automatically get attached to request so there aren't XSRF worries.
(You still need to be careful of XSS of course.)
* it is persistent across refreshes
* it remains even if you leave page to another domain then return to page on same tab
* it disappears if the tab is closed
* it doesn't change as you navigate back/forward
* would be most useful with xhr requests or a hidden field in form post requests.
Downsides:
* no origin security
* no obvious nice way to use with page GETs for server to know which tab a page request is from.