Reputation: 3
I am working on an autologoff feature in a website that will kick out the user after 60 minutes of inactivity. I am using cookies to store the number of seconds during inactivity so that when the value reaches to 60 minutes. It logsout the user. It works perfectly all right when I test them in a single tab on chrome.
But when I open the same site in multiple tabs (2 tabs). The counter in the cookie starts counting faster because of both the tabs updating the same cookie at the same time. So, in this case, the user gets logged out in about 30-40 minutes of inactivity.
Any ideas or suggestions to fix this?
Upvotes: 0
Views: 756
Reputation: 169
https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage this should help
Opening a page in a new tab or window will cause a new session to be initiated with the value of the top-level browsing context, which differs from how session cookies work.
Or you can save date in cookie, and check if from now past x time.
Upvotes: 1