Answer the question
In order to leave comments, you need to log in
How to correctly delete a cookie using Express?
I'm trying to use the res.clearCookie
method , passing the same parameters to it that were assigned to the cookie during installation.
If I understand correctly, the server cannot directly indicate to the client that the cookie should be deleted, so the above method stupidly overwrites the file in such a way that Value is reset to zero, and Expired turns out to be the moment the server response was sent to the client (i.e., the cookie instantly expires).
First, I want to clarify whether I really understand the behavior of Express correctly?
The second point is that Chrome (with basic settings) does not delete the cookie. It keeps hanging empty:
Is this normal behavior or am I doing something wrong?
And if it's normal, then how can I delete the cookie? Maybe in the middleware check for empty cookies and explicitly overwrite them with the session flag so that the browser is guaranteed to delete them after the window closes?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question