Koa: how to delete a cookie

Created on 15 Jul 2016  路  12Comments  路  Source: koajs/koa

I tried ctx.cookies.set('jwt', null), but the cookie still there.

Most helpful comment

For anyone arrive here, ctx.cookies.set('jwt', null) works in postman now.

All 12 comments

I found it worked in browser, but not worked in Postman, erm..

just set a outdated expire date

@luckydrq I know the way you said, ctx.cookies.set('jwt', null) this code works, but only in browser, I found that is Postman's bug.

ok, but what is Postman?

@luckydrq It's a tool to test api, here

@luckydrq I know the way you said, ctx.cookies.set('jwt', null)

yeath, you're right. It's the same as set a outdated date. I've found the clue: https://github.com/pillarjs/cookies/blob/master/lib/cookies.js#L113

For anyone arrive here, ctx.cookies.set('jwt', null) works in postman now.

ctx.cookies.set(cookieName, '');

actually, looks like it's just ctx.cookies.set(cookieName)

ok, but what is Postman?

https://www.getpostman.com/ It's a good tool for testing api

ok, but what is Postman?

https://www.getpostman.com/ It's a good tool for testing api

restlet client run in chrome,this is better

actually, looks like it's just ctx.cookies.set(cookieName)

this is correct, per the documentation for cookies.set

If the _value_ is omitted, an outbound header with an expired date is used to delete the cookie.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coodoo picture coodoo  路  4Comments

tracker1 picture tracker1  路  3Comments

usernameisalreadytaken2014 picture usernameisalreadytaken2014  路  4Comments

sibelius picture sibelius  路  3Comments

rainesinternationaldev picture rainesinternationaldev  路  5Comments