-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
Closed
Labels
Description
If a cookie with a maxAge is set, performing res.clearCookie() will not clear the cookie.
We update the expiry in clearCookie() so the expires property is overriden to a past date:
res.clearCookie = function clearCookie(name, options) {
var opts = merge({ expires: new Date(1), path: '/' }, options);
return this.cookie(name, '', opts);
};But then when this.cookie() is called, it sees the cookie has a maxAge property, which will override the expiry date in this code:
if ('maxAge' in opts) {
opts.expires = new Date(Date.now() + opts.maxAge);
opts.maxAge /= 1000;
}and the cookie therefore wouldn't be cleared (In fact, it would actually cause the cookie's expiry date to be further into the future).