Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Cannot set multiple cookies because set-header overwrites set-cookie #67

@ArthoPacini

Description

@ArthoPacini

Hi,

The Set-Cookie HTTP response header is used to send cookies from the server to the user agent, so the user agent can send them back to the server later.

The only way to set headers in served is to use the function set_header() from the request object, like so

res.set_header("Set-Cookie","foo=1");

this way, when the client get the response from the request, it gets the Cookie "foo" with a value of 1

The problem is that, in a specific request, the server may set two or more cookies, like foo=1 and bar=2,

but running

res.set_header("Set-Cookie","foo=1");
res.set_header("Set-Cookie","bar=2");

actually only sends the last key-value pair bar=2, because the request class is using a std::unordered_map<std::string, std::string> header_list

so the last value overwrites the first

also it seems that passing two cookies into one Set-Cookie is not supported on Chrome, so

res.set_header("Set-Cookie","foo=1; bar=2");
or
res.set_header("Set-Cookie","foo=1, bar=2");

does not work

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