How not to lose the session from one tab to another? [duplicate]

0

I'm trying to create a login in which after validating that the username and password are correct create in the sessionStorage the following variable:

sessionStorage.setItem('ClienteId', resp.ClienteId);

Doing so when entering each page I check before the client exists in the session, but when changing the tab I lose the same. Would you like to work without losing it?

Or some better way to login? Thank you in advance.

    
asked by anonymous 23.10.2017 / 20:03

2 answers

1

For this you can use localStorage , where you can shared between the browser tabs.

    
23.10.2017 / 20:06
0

I think using sessionStorage is a good option, since it will not persist data, while localStorage will do so.

That is, if you restart the browser for example, the sessionStorage data will be deleted (non-persistent), while the data will remain in the localStorage.

There goes your need. I believe in your case, because it is a client ID, the interesting thing is to 'go away' with it when you close the browser, then sessionStorage itself.

    
23.10.2017 / 20:56