Skip to content

Cookie's don't clear if maxAge is set #4252

Description

@harryjamesuk

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions