Skip to content
Download

cookie

mach::Response::cookie

Returns a response cookie.

Returns the cookie with the specified name.

[[nodiscard]] std::optional<mach::http::Cookie> cookie(std::string_view name) const;

The cookie, or std::nullopt if the response does not contain a cookie with the specified name.

Parameter Description
name The name of the cookie to return.
Exception Condition
std::bad_alloc Thrown if memory allocation fails.

Cookie names are case-sensitive.

This function is thread-safe.

if (auto cookie = response().cookie("session")) {
// Use *cookie...
}
Name Description
Cookie Represents an HTTP cookie.
containsCookie Checks whether the response contains a cookie.
addCookie Adds a cookie to the response.