Module

http.cookies

Cookie parsing and SetCookie serialization.

Consolidates the read side (parse_cookies, used by Request) and the write side (SetCookie, used by Response) in one module.

Classes

SetCookie 9
A ``Set-Cookie`` directive attached to a Response.

ASet-Cookiedirective attached to a Response.

Attributes

Name Type Description
name str
value str
max_age int | None
path str
domain str | None
secure bool
httponly bool
samesite str

Methods

to_header_value 0 str
Serialize to a ``Set-Cookie`` header value string.
def to_header_value(self) -> str
Returns
str

Functions

parse_cookies 1 dict[str, str]
Parse a ``Cookie`` header value into a name-value dict. Returns an empty dict …
def parse_cookies(header: str) -> dict[str, str]

Parse aCookieheader value into a name-value dict.

Returns an empty dict for empty or missing headers.

Parameters
Name Type Description
header str
Returns
dict[str, str]