title: How can I logout a user from all open tabs automatically when user logs out in one of them?
body: <p>I have created a Login page, amongst many others pages, which contains code to check the session. If the user doesn't have a session then all pages will reload and redirect to the logout page. This script is called every three seconds.</p>
  <p>The code I've written is working fine but I want implement it another way. When the user logs out, all open tabs reload/refresh causing the user to be logged out. Is that possible?</p>
  <p><strong>sessioncheck.php</strong>:</p>
  <pre><code>&lt;?php
  session_start();
  if(isset($_SESSION['username']) &amp;&amp; $_SESSION['username'] != ''){
      echo &quot;true&quot;;
  }
  else {
      echo &quot;false&quot;;
  }
  ?&gt;
  </code></pre>
  <p>This code is in every page footer:</p>
  <pre><code>&lt;script&gt;
      function gettatus(){
          $.get(&quot;sessioncheck.php&quot;, function(data){
              if(!data) {
                  window.location = &quot;logout.php&quot;;
              }
              setTimeout(function(){
                  checkLoginStatus();
              }, 3000);
          });
      }
      $(document).ready(function(){
          gettatus();
      });
  &lt;/script&gt;
  </code></pre>