wreq.cookie
Cookie management and storage for maintaining session state.
wreq.cookie
HTTP Cookie Management
This module provides classes for creating, managing, and storing HTTP cookies in a thread-safe manner. It includes support for all standard cookie attributes and provides a cookie jar for automatic cookie handling during HTTP requests.
SameSite
Cookie
A cookie.
Source code in python/wreq/cookie.py
same_site_strict
instance-attribute
Returns true if 'SameSite' directive is 'Strict'.
__init__
__init__(name, value, domain=None, path=None, max_age=None, expires=None, http_only=None, secure=None, same_site=None)
Create a new cookie.
Source code in python/wreq/cookie.py
Jar
A thread-safe cookie jar for storing and managing HTTP cookies.
Jar can be shared across multiple threads and tasks. When passed to a
client, it is used to automatically persist and send cookies across
requests and responses.
Protocol-level behaviour
- HTTP/1.1 — all cookies are folded into a single
Cookieheader, as required by RFC 9112 §5.6.3. - HTTP/2 and above — each cookie is sent as an individual header field per RFC 9113 §8.1.2.5.
Source code in python/wreq/cookie.py
__init__
get
Look up a cookie by name scoped to the given URL.
Domain matching is exact: only cookies whose domain exactly matches the URL host are considered. Subdomains are not matched.
Returns None if no matching cookie is found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The cookie name to look up. |
required |
url
|
str
|
The URL used for exact domain matching and path matching. |
required |
Source code in python/wreq/cookie.py
get_all
add
Insert a cookie into the jar, scoped to the given URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cookie
|
Cookie | str
|
A |
required |
url
|
str
|
The URL the cookie originates from (used for domain / path scoping). |
required |
Source code in python/wreq/cookie.py
remove
Remove a cookie by name, scoped to the given URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The cookie name to remove. |
required |
url
|
str
|
The URL the cookie is scoped to. |
required |