express icon indicating copy to clipboard operation
express copied to clipboard

`res.clearCookie()` does not ignore `maxAge`

Open tjarbo opened this issue 1 year ago • 6 comments

Hi everyone! I just ran into a bug, where res.clearCookie() does not work properly.

What happen?

According to the typescript definitions, res.clearCookie() accepts CookieOptions as a second parameter (see here) which includes the maxAge attribute. But if the maxAge is set, the cookie won't be deleted.

What do I expect?

.clearCookie()should ignore (or delete) the maxAge attribute, because it is used to calculate the expire attribute afterwards in .cookie();


I already located the bug and would like to provide a pr to fix this.

tjarbo avatar Mar 08 '22 15:03 tjarbo

I had the same problem a few days ago, thanks for the pr i want to try when it merged

yagmurmutluer9 avatar Mar 13 '22 13:03 yagmurmutluer9

Thank you for your work on this @tjarbo !

dougwilson avatar Mar 13 '22 18:03 dougwilson

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.

dougwilson avatar Mar 24 '22 03:03 dougwilson

Added a review for tgarbo's PR

Segmentational avatar Jun 28 '22 19:06 Segmentational

Thank you @Segmentational !

tjarbo avatar Jul 04 '22 09:07 tjarbo