Answer the question
In order to leave comments, you need to log in
Where to store user credentials?
Hello! I ran into a problem that I do not know where to store the data of an authorized user.
I send localStorage to the client - he does not see, and this does not seem like a good idea.
And output through template engines is not suitable, because after refreshing the page, all information disappears, and you need to log in again.
How can this be resolved?
Answer the question
In order to leave comments, you need to log in
1. localStorage is not sent! Used only on the client side.
2. On the server you send res.json({ userInfo })
On the client you receive a response from the server, then localStorage.setItem('auth', token). If you need to take info then localStorage.getItem('auth')
3. Use jwt authorization to not store data in unencrypted form.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question