Skip to content
Download

addCookie


mach::Response::addCookie

Adds a cookie to the response.

Adds the specified cookie to the response.

// (1)
void addCookie(const mach::http::Cookie& cookie);
// (2)
void addCookie(mach::http::Cookie&& cookie);
// (3)
void addCookie(std::string name, std::string value);
Parameter Description
cookie The cookie to add.
Parameter Description
cookie The cookie to add.
Parameter Description
name The cookie name to add.
value The cookie value to add.
Exception Condition
std::bad_alloc Thrown if memory allocation fails.

Copies the specified cookie into the response.

Moves the specified cookie into the response.

Adds a cookie with the default options.

This function is not thread-safe.

mach::http::Cookie cookie;
cookie.name = "session";
cookie.value = "abc123";
response().addCookie(cookie);
mach::http::Cookie cookie;
cookie.name = "session";
cookie.value = "abc123";
response().addCookie(std::move(cookie));
response().addCookie("theme", "dark");
Name Description
Cookie Represents an HTTP cookie.
cookie Returns a response cookie.
containsCookie Checks whether the response contains a cookie.