cookies node.js

Destroy cookie NodeJs

I am using Cookies module for setting cookie. Here is following my code:

var options = {
domain: '',
expires: new Date( + ALMOST_ONE_HOUR_MS)
var value = userInfo.token;
cookies.set("testtoken", value, options);

But in documentation I haven’t found how to destroy this cookie.

Any suggestion would be appreciated.

There is no way to delete a cookie according to the HTTP specification. To effectively “delete” a cookie, you set the expiration date to some date in the past. Essentially, this would result in the following for you (according to the cookies module documentation):

cookies.set('testtoken', {maxAge: 0});

Or according to the HTTP specification:

cookies.set('testtoken', {expires:});

Both of which should work. You can replace with new Date(0) for a really old date.