title: Is localStorage connection-dependent?
body: <p>I made a small JavaScript math game for my kids that stores a high score using <code>localStorage</code>.  It works fine, does what it's supposed to do, and saves the high score even when the browser is closed or computer is turned off.  However, today I tried to play the game for testing over a different Internet connection, and the two <code>localStorage</code> items I used (one for the score, one for the name) both returned <code>undefined</code>.</p>
  
  <p>Both times the game was played in Chrome v55 in Windows 7 (same PC).  Originally it was over our home Wi-Fi connection, but today it was over a public (coffee shop) Wi-Fi connection.</p>
  
  <p><code>localStorage</code> still works over the public Wi-Fi connection -- I can set new values and retrieve them -- but I'm wondering why it didn't store the original values.  No browser history or cookies have been cleared.  Does anyone know if <code>localStorage</code> has separate containers for different Internet connections?</p>
  
  <p>UPDATE: The <code>localStorage</code> object works fine -- it saves and persists data -- the only problem is that when retrieved when connected to a different network connection, it loses the values.</p>
  
  <p>This is the code used to get data from <code>localStorage</code>:</p>
  
  <p><code>
  if (localStorage.mb_hiscore == 0) { localStorage.mb_name = " "; }
      hiscore.innerHTML = localStorage.mb_hiscore + "&lt;br /&gt;" + localStorage.mb_name;
  </code></p>
  
  <p>Update again: Chrome shows the same origin on both the public Wi-Fi and my home Wi-Fi:</p>
  
  <p><a href="https://i.stack.imgur.com/o96B8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o96B8.png" alt="origin setting, file"></a></p>
  
  <p>Also, the <code>localStorage</code> values I set while on the public Wi-Fi connection persisted to when I retrieved them later, on my home network, so it's only the one time so far that Chrome dropped the values.</p>