title: Angular 2 : Logout all open tabs automatically when user logs out in one of them
body: <p>I have created Login page, based on sessionstorage. On loading the page I have checked the value of sessionstorage. If I opened the web page in more than one tab and then I logout from any one of the tabs, all the remaining pages should logout automatically.</p>
  
  <p>Please help me to run a script, when user view the page or say any other way to solve this problem.</p>
  
  <p>On click of logout button</p>
  
  <pre><code>logout() {
  
   const userLoggedOut = this.loginService.changeStatusLogout(this.isAuthenticated.getLoginStatus(),                                                            this.isAuthenticated.getLoggedInUserID());
  if (userLoggedOut) {
    const link = ['login'];
    this.router.navigate(link);
   }
  }
  
  changeStatusLogout(status: boolean, userID){
    if (userID &amp;&amp; status) {
      sessionStorage.removeItem('userID');
      sessionStorage.removeItem('userGroup');
      sessionStorage.removeItem('userLogedIn');
    return true;
    }
  }
  
  getLoginStatus() {
      const checkStaus = sessionStorage.getItem('userLogedIn');
      if (checkStaus === 'true') {
      return this.userLoggedIn = true;
      }
  }
  
  getLoggedInUserIDGroup() {
    const loggedInUserGroup = sessionStorage.getItem('userGroup');
    return loggedInUserGroup;
    }
  </code></pre>