9

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.

Charklewis
  • 4,427
  • 4
  • 31
  • 69

1 Answers1

8

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 :)

Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
  • 1
    Looks like there are a few solutions if you need the cross domain support. I'll do some research on this when I need to that type of solution. Thanks for pointing me in the right direction. – Charklewis Dec 23 '18 at 22:31