cookies icon indicating copy to clipboard operation
cookies copied to clipboard

ability to clear cookie

Open goldensunliu opened this issue 10 years ago • 6 comments

expose a method in the API to clear/expire a cookie

like how they do here http://expressjs.com/api.html#res.clearCookie

goldensunliu avatar Aug 12 '15 21:08 goldensunliu

+1 really needed feature

yekver avatar Sep 14 '15 16:09 yekver

Please feel free to make a PR if you are looking for the feature soon.

dougwilson avatar Sep 14 '15 17:09 dougwilson

Would setting maxAge to -1 not do it?

rjmunro avatar Jan 18 '16 12:01 rjmunro

Even setting maxAge to 0 will work; I think the ask here is to have an API that is clear that the operation is to clear the cookie, instead of needed everyone to understand that setting a cookie that will immediately expire will do that.

dougwilson avatar Jan 18 '16 15:01 dougwilson

@dougwilson Looking at the code, I think setting maxAge to 0 won't work as 0 is falsey - setting it to 0 means that it will be ignored. The code here does:

if (this.maxAge) this.expires = new Date(Date.now() + this.maxAge);

rjmunro avatar Jan 20 '16 12:01 rjmunro

Waitting to add destory function to cookie.

shuperry avatar Jul 21 '16 02:07 shuperry