addCookie
mach::Response::addCookie
Adds a cookie to the response.
Description
Section titled “Description”Adds the specified cookie to the response.
Syntax
Section titled “Syntax”// (1)void addCookie(const mach::http::Cookie& cookie);
// (2)void addCookie(mach::http::Cookie&& cookie);
// (3)void addCookie(std::string name, std::string value);Parameters
Section titled “Parameters”Overload (1)
Section titled “Overload (1)”| Parameter | Description |
|---|---|
cookie |
The cookie to add. |
Overload (2)
Section titled “Overload (2)”| Parameter | Description |
|---|---|
cookie |
The cookie to add. |
Overload (3)
Section titled “Overload (3)”| Parameter | Description |
|---|---|
name |
The cookie name to add. |
value |
The cookie value to add. |
Exceptions
Section titled “Exceptions”| Exception | Condition |
|---|---|
std::bad_alloc |
Thrown if memory allocation fails. |
Remarks
Section titled “Remarks”Overload (1)
Section titled “Overload (1)”Copies the specified cookie into the response.
Overload (2)
Section titled “Overload (2)”Moves the specified cookie into the response.
Overload (3)
Section titled “Overload (3)”Adds a cookie with the default options.
Thread Safety
Section titled “Thread Safety”This function is not thread-safe.
Examples
Section titled “Examples”Overload (1)
Section titled “Overload (1)”mach::http::Cookie cookie;cookie.name = "session";cookie.value = "abc123";
response().addCookie(cookie);Overload (2)
Section titled “Overload (2)”mach::http::Cookie cookie;cookie.name = "session";cookie.value = "abc123";
response().addCookie(std::move(cookie));Overload (3)
Section titled “Overload (3)”response().addCookie("theme", "dark");See Also
Section titled “See Also”| Name | Description |
|---|---|
Cookie |
Represents an HTTP cookie. |
cookie |
Returns a response cookie. |
containsCookie |
Checks whether the response contains a cookie. |