Scope of sessionStorage and localStorage

Session Storage:

  1. Values persist only as long as the window or tab in which they stored.

  2. Values are only visible within the window or tab that created them.

Local Storage:

  1. Values persist window and browser lifetimes.

  2. Values are shared across every window or tab running at the same origin.

So, by reading and understanding this each key-value pair is unique for each domain, because local storage persist values across window or tab.


The values are going to overwrite each other. Each key-name pair is unique for a protocol and domain, regardless of the paths.

The affected domain can be changed via the document.domain property.

  • sub.example.com -> example.com is possible (subdomain)
  • sub.example.com -> other.example.com is not possible