• 1.7k
  • 243
  • 47.4k

Logout all tab for same user

Aug 23 2019 2:33 AM
Hello Experts,
when i am click on logout button in one tab it should be logout all open tab for same user in same browser in angular 7.
I am tried using localstorage below is code but in that case i m getting event on second tab. but i am not able to use same componet method in window.addEventListener.
even i tried document.addEventListener but it is not working.
storageChange() {
localStorage.setItem('logout-event', 'logout' + Math.random());
window.addEventListener('storage', function (event) {
// do what you want on logout-event
if (event.key == 'logout-event') {
console.log('Received logout event! Insert logout script here.');
console.log('Received logout event! after clear storage');
please help me is there any other solution for same.
Thank you

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (3)