std1.0.0-beta-7 SafeC docs

Module http::cookie

#include <std/http/cookie.h> source

HTTP cookies (RFC 6265).

Reading: a request's "Cookie: a=1; b=2" header parsed into name/value pairs (CookieList, or HttpRequest::cookie() in std/http/http.h for one value). Writing: SetCookie builds a "Set-Cookie" header value with its attributes; http_set_cookie adds one to a response. SetCookie::parse reads one back (what a client stores).

Values are taken and written verbatim (RFC 6265 allows no escaping): a value with spaces, ';', ',' or '"' should be encoded by the caller — url_encode/form_encode (std/encoding/url.h) are the usual choice.

Structs

CookiePair
CookieListThe cookies of one Cookie header, in order.
SetCookie

Functions

http_set_cookieAppends "Set-Cookie: <c.to_string()>" to the response's headers (one per call; several cookies mean several calls).

Macros

COOKIE_SAMESITE_UNSET
COOKIE_SAMESITE_LAX
COOKIE_SAMESITE_STRICT
COOKIE_SAMESITE_NONE