To do this, you should depend on the server. Creating something like GetCurrentUser on the server. If the user is logged in, he returns all the properties of the user.
You should even use this api server to receive user data after authentication is complete. Thus, authentication becomes a two-step process, firstly, user authentication, upon successful completion of another call, the server receives the current user data.
Using local storage on the client side for this would not be ideal, because you had to do a lot of accounting in terms of cleaning up a registered user when you log out or expire a session.
Also, cookies from the server will have an expiration time, and making a decision based on cookies existing on local storage may not be optimal.
Chandermani
source share