Answer the question
In order to leave comments, you need to log in
What is the best way to set cookies?
The question is, when sending a request to the server and a successful response, return the cookie value in the response and set the value on the client via document.cookie, or indicate in the response itself that it is necessary to set cookies via res.cookie(...)?
Answer the question
In order to leave comments, you need to log in
It depends on what you are going to write there and depending on where this data is needed.
If this is data that is used only by the client and the server does not use it in any way, then it is better through document.cookie. Otherwise, res.cookie.
Token and other confidential data for identification, in a good way, write to the HttpOnly cookie on the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question