5

I am trying to clear two cookies in my clients browser via the following:

this.response.set('Set-Cookie', 'mycookie1=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; ,mycookie1.sig=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT;');

I can only seem to get rid of mycookie1 and not the mycookie.sig.

basickarl
  • 37,187
  • 64
  • 214
  • 335

1 Answers1

4

It's more about the protocol (HTTP). You should split it into two header fields (Set-Cookie for each cookie).

By RFC6265:

An origin server can include multiple Set-Cookie header fields in a single response. ... Origin servers SHOULD NOT fold multiple Set-Cookie header fields into a single header field.

There is a better way to set cookies with Koa than the raw way, two cookies are set by call it simply twice (see the docs for the possible options):

function *() {
    this.cookies.set('mycookie1', 'value1', options);
    this.cookies.set('mycookie2', 'value2', options);
}
Community
  • 1
  • 1
Roy Miloh
  • 3,381
  • 1
  • 18
  • 17