-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
res.clearCookie()
does not ignore maxAge
#4851
Comments
I had the same problem a few days ago, thanks for the pr i want to try when it merged |
Thank you for your work on this @tjarbo ! |
Please see #4252 for related discussion. This was original designed this way on purpose (ugh), and I see it being used in the wild this way. We can land such a change in the 5.0 branch, so I'm setting it to 5.0. |
Added a review for tgarbo's PR |
Thank you @Segmentational ! |
Since #4252 is closed, I'll continue the discussion here: As all the other options (domain, sameSite, etc) needs to be the same when clearing the cookie as when setting it, the natural thing to do is use the same Big thanks to @tjarbo for identifying the problem and provding a PR! |
I don't think this is semver major, I think this is just a bug which we can fix in a patch According to the v4 docs https://expressjs.com/en/api.html#res.clearCookie
The implementation today does not reflect the documented behavior. The method itself does not have the ability to "clear cookies" at all, it relies on browser behavior. And if we allow This is the entire intent of the method, and it has a bug today. |
I think this is an incorrect interpretation of the docs and intent behind the commits related that got us here:
and
And more here
commit historySupport for There was no indication in the change that it was meant to allow a cookie's value to be cleared by this method, while still persisting the cookie clientside via extended "Clearing" a cookie means deleting it in the browser by setting During the v4 release, there is no mention of supporting this alternative usecase for It's my opinion that the options feature introduced introduced a bug by allowing folks to prevent
|
Hi everyone!
I just ran into a bug, where
res.clearCookie()
does not work properly.What happen?
According to the typescript definitions,
res.clearCookie()
acceptsCookieOptions
as a second parameter (see here) which includes themaxAge
attribute. But if themaxAge
is set, the cookie won't be deleted.What do I expect?
.clearCookie()
should ignore (or delete) themaxAge
attribute, because it is used to calculate theexpire
attribute afterwards in.cookie()
;Research
I already located the bug and would like to provide a pr to fix this.
The text was updated successfully, but these errors were encountered: