I am using sessionStorage
to ensure an action only happens once per session. However, if a user opens a new window - the sessionStorage
is not carried over to the new window, and the action is executed again. See my code below:
if sessionStorage.alreadyTracked != "1"
sessionStorage.alreadyTracked = "1"
...
Is there an easy way to do this that applies to all tabs? Maybe I need to use a cookie?
As far as html5 storage goes i would go for localStorage in your case.
See below for the differences.
Session Storage:
Local Storage:
Read more here
You probably want to switch to localStorage
as sessionStorage
is bound to individual tabs and localStorage
is not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With