Simple Way to Log Out a User From All Browser Tabs
Developers will often want to logout/login a user automatically from all the open tabs/windows.
Let's say you are developing a Single Page Application using realm-web
JS SDK.
A user journey of the app will look like this: A user logs in with app.logIn(credentials)
, and opens multiple tabs/windows on the browser. Then the user clicks the "Log out" button inside one of the tabs, and switches to another tab. The app UI remains the same, but http requests will fail.
Although you might think it's a problem that each developer should tackle with, please consider to provide a native solution in realm-web
, if you think it's a common usecase for modern internet users.
JFYI, one of the solutions would be listening to changes of LocalStorage by window.addEventListener("storage")
, and it looks relatively simple to achieve:https://medium.com/front-end-weekly/multi-tab-logout-in-react-redux-4715f071c7fa
![](https://secure.gravatar.com/avatar/2bd427f41a5dcd34d9df9400547d631d?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)