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
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_listso 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