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=functionclearCookie(name,options){varopts=merge({expires: newDate(1),path: '/'},options);returnthis.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'inopts){opts.expires=newDate(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).
If a cookie with a
maxAgeis set, performingres.clearCookie()will not clear the cookie.We update the expiry in
clearCookie()so theexpiresproperty is overriden to a past date:But then when
this.cookie()is called, it sees the cookie has amaxAgeproperty, which will override the expiry date in this code: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).