Q:

Fail to read localStorage

I have a plunker to set a value in localStorage:
<!DOCTYPE html>
<html>
  <script>
    localStorage.setItem('test', "hadddddha");
  </script>
</html>

And I have a code http://www.addbba.com/testLocalStorage.html to get it:
<!DOCTYPE html>
<html>
  <script>
    var test = localStorage.getItem('test');
    console.log(test)
  </script>
</html>

Oddly, the console shows the value is null. Does anyone know what happened?

A:

According to https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage localStorage is specific to a document's origin. Can you confirm that you are reading a value from localStorage using the same origin as where you wrote the value?

