cookie
mach::Response::cookie
Returns a response cookie.
Description
Section titled “Description”Returns the cookie with the specified name.
Syntax
Section titled “Syntax”[[nodiscard]] std::optional<mach::http::Cookie> cookie(std::string_view name) const;Return Value
Section titled “Return Value”The cookie, or std::nullopt if the response does not contain a cookie with the specified name.
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
name |
The name of the cookie to return. |
Exceptions
Section titled “Exceptions”| Exception | Condition |
|---|---|
std::bad_alloc |
Thrown if memory allocation fails. |
Remarks
Section titled “Remarks”Cookie names are case-sensitive.
Thread Safety
Section titled “Thread Safety”This function is thread-safe.
Example
Section titled “Example”if (auto cookie = response().cookie("session")) { // Use *cookie...}See Also
Section titled “See Also”| Name | Description |
|---|---|
Cookie |
Represents an HTTP cookie. |
containsCookie |
Checks whether the response contains a cookie. |
addCookie |
Adds a cookie to the response. |