title: How to combine advantages of localStorage and sessionStorage
body: <p>I want to share my authentication token between browser tabs which would suggest to use <a href="https://developer.mozilla.org/en/docs/Web/API/Window/localStorage" rel="noreferrer">HTML5 <code>localStorage</code></a>. But I don't want anything related to authentication to stay in my storage when the browser is closed which would suggest using <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage" rel="noreferrer">HTML5 <code>sessionStorage</code></a>.</p>
  
  <p><strong><a href="https://stackoverflow.com/questions/20325763/browser-sessionstorage-share-between-tabs">Reference 1 related to this topic (click)</a>:</strong></p>
  
  <blockquote>
    <p>That means that you can't share between tabs, for this you should use localStorage</p>
  </blockquote>
  
  <p><strong><a href="https://www.owasp.org/index.php/HTML5_Security_Cheat_Sheet#Local_Storage" rel="noreferrer">Reference 2 related to this topic (click)</a>:</strong></p>
  
  <blockquote>
    <p>Therefore, it's recommended not to store any sensitive information in local storage</p>
  </blockquote>
  
  <p>How can I combine the sharing of my authentication token between tabs and still make sure that when the browser closes nothing stays behind in storage?</p>
  
  <p>How do other websites solve this seemingly simple problem.</p>