Skip to content

How to set multiple Set-Cookie headers in a single response? #231

@kentcdodds

Description

@kentcdodds

I tried copying concatSetCookieHeaders from remix but that... eh, doesn't work... Doing that I end up with a single set-cookie header.

Here's the relevant code:

const sessionIdCookie = await getUserSessionCookieFromMagicLink(request)
if (sessionIdCookie) {
  const destroyCookie = await loginInfoSession.destroy()
  return redirect('/me', {
    headers: {
      'Set-Cookie': concatSetCookieHeaders(destroyCookie, sessionIdCookie),
    },
  })
}

What I need is two Set-Cookie headers, and this gives me a single Set-Cookie header that doesn't end up updating either one.

If I use either of these cookie values by itself then they each work as expected. But I need to set them both in the same response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions