Do subdomains share local storage?

Viewed 4270

I'm currently building two react apps with both storing a redux state in local storage.

Will the example domains below share the same local storage?

  1. www.website.com
  2. admin.website..com

Due to the nature of the apps, I do not want their local storage to be shared and hoping this is the default behaviour.

1 Answers

localStorage is based on a Document's origin. For example, the origin of this page is:

self.origin; // "https://stackoverflow.com"

So, no, localStorage will not be shared across subdomains. If you did want to share localStorage across sub-domains, there is a solution here on SO for that :)

Related