1

A newbie Question here, I have searched on stackOverflow and nothing has answered my question...

I have a home site lets say homesite.com there I have a login and if everything went smoothly I redirect the user to app.homesite.com there I look at the session or localstorage to see if it is a valid user

my question is how can I have the session or localstorage always saved? because when my page changes to another url the memory is gone... I am testing the pages locally localhost8808 and localhost9000 I don't know if this has something to do with that

Hyra10
  • 460
  • 2
  • 6
  • 18
  • 1
    Possible duplicate: http://stackoverflow.com/questions/25064233/using-session-storage-across-subdomains – Rory McCrossan Jun 06 '16 at 21:21
  • 1
    The following link is fairly old, so I'm not sure on if the spec for local storage has changed, but 3-4 years ago this was the work around for domain/subdomain and local storage: http://stackoverflow.com/a/7722326/1992129 – Arthur Weborg Jun 06 '16 at 21:21
  • 1
    Possible duplicate of [use localStorage across subdomains](http://stackoverflow.com/questions/4026479/use-localstorage-across-subdomains) – Heretic Monkey Jun 06 '16 at 21:23
  • 1
    @ArthurWeborg - I second this link. You're running into a restriction with accessing Local Storage *across domains*. Local storage will work between pages, but not natively across domains, subdomains (www, app, etc), or ports – Alex Johnson Jun 06 '16 at 21:24

1 Answers1

0

LocalStorage saves data permanently until deleted by developer or user . Session storage is only available in current window . If you are already using local storage and your data is clearing when url changes you will probably need to configure your domain to :

Example :

app.homesite.com/home

app.homesite.com/login

app.homesite.com/profile

ect...

KpTheConstructor
  • 3,153
  • 1
  • 14
  • 22