Hi,
When you logout, all tabs should also be logged out too since cookies are common to all tabs, but they are not refreshed.
In order to force refresh, you can use the browser BroadcastChannel feature. The idea is to register all tab on a BroadcastChannel whose name is the sessionId:
var myChannel = new BroadcastChannel("my-session-id");
myChannel.addEventListener("message", onMessage);
The "
onMessage" function performs a redirection to a page that info that user has been logged out:
function
onMessage(ev) {
if (ev?.data?.message == 'logout') {
window.open("url-to/disconnected.jsp", "_self");
}
}
Now, when a tab logs out, it can simply post the "logout" message, then all tab that are registered on same channel will execute the code above.
function logout() {
// do logout stuff
// ...
// broadcast logout message
if (myChannel) {
myChannel.postMessage({ message: 'logout' });