title: Misunderstanding concept of localStorage
body: <p>I'm using this code published by Sasi Varunan  <a href="https://stackoverflow.com/questions/23690666/check-if-my-website-is-open-in-another-tab">here</a></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          // Broad cast that your're opening a page.
          localStorage.openpages = Date.now();
  
          var onLocalStorageEvent = function(e){
              if(e.key == "openpages"){
                  // Listen if anybody else opening the same page!
                  localStorage.page_available = Date.now();
              }
              if(e.key == "page_available"){
                  alert("One more page already open");
              }
          };
          window.addEventListener('storage', onLocalStorageEvent, false);
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Code is working like charm</strong> - doing exactly what I want - detect if an application it's already open in another tab browser or even in another browser window.</p>
  
  <p>From my understanding: </p>
  
  <p>The very first time when the application is started the followings thinks happen:</p>
  
  <ol>
  <li>App set <code>openpages</code> key with <code>Date.now()</code> value.</li>
  <li>Because of 1. storage event listener start <code>onLocalStorageEvent</code> event.</li>
  <li>Because the <code>openpages</code> key exists, is setting <code>page_available</code> key with Date.now ()</li>
  <li>When the followings apps are started they find <code>page_available</code> key in storage (the second if) the alert is triggered and I can redirect them to an error page.</li>
  </ol>
  
  <p><strong>QUESTION:</strong></p>
  
  <p>If I close all the browser windows and restart the app in a new winwdow everything still works fine. </p>
  
  <p>This is what I don't understand because the <code>page_available</code> key is persistent is still there in the storage (no one deleted) the app should go on the second if and that the alert ... but this is not happening.</p>