Registry / http-networking / cookies

cookies

JSON →
library2.2.1pypypiunverified

The `cookies` library (by Sasha Hart) is a Python module designed for parsing and rendering RFC 6265-compliant HTTP `Cookie:` request headers and `Set-Cookie:` response headers. It offers a cleaner API compared to the standard library's `http.cookies` and explicitly adheres to modern cookie standards, eschewing backward compatibility with older, less compliant RFCs (like 2109 or 2965). The last release was in 2014 (v2.2.1), and there is no apparent active development, suggesting it is no longer maintained.

pip install cookies
INSTALL
IMPORT
SIG · COOKIES
C
cookies
http-networkingpythonv2.2.1
Install
1.5s avg
Import
38ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.018s · 18MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.012s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cookies
from cookies import Cookies
from http.cookies import SimpleCookie
This library is designed as a replacement for http.cookies and has a different API.
Cookie
from cookies import Cookie

Demonstrates creating, manipulating, and rendering 'Set-Cookie' headers, and parsing 'Cookie' request headers.

from cookies import Cookies, Cookie # Create a Cookies object for response headers response_cookies = Cookies() response_cookies['session_id'] = 'abc123def456' response_cookies['session_id'].path = '/' response_cookies['session_id'].max_age = 3600 # 1 hour # You can also set using a Cookie object directly my_cookie = Cookie('user', 'guest') my_cookie.domain = 'example.com' response_cookies.add(my_cookie) print('Set-Cookie Headers:') for header_line in response_cookies.render_response(): print(header_line) # Simulate receiving a Cookie header from a request request_header_string = 'session_id=abc123def456; other_data=some_value' request_cookies = Cookies.from_request(request_header_string) print('\nParsed Request Cookies:') for name, cookie in request_cookies.items(): print(f" {name}: {cookie.value}") # Access a specific cookie if 'session_id' in request_cookies: print(f"Session ID from request: {request_cookies['session_id'].value}")
Debug
Known issues
breakingThe library explicitly does NOT maintain backward compatibility with Python's standard library `Cookie.py` (now `http.cookies`), RFC 2109, or RFC 2965. Its API is different and it adheres strictly to RFC 6265.
fix
Do not treat this library as a drop-in replacement for `http.cookies`. Adapt your code to its distinct RFC 6265-compliant API.
affects: All versions
deprecatedThe library reached version 2.2.1 in September 2014 and has not been updated since. It is compatible with Python 2.6, 2.7, 3.2, 3.3, and PyPy (2.7), but is unlikely to work with newer Python 3.x versions (e.g., Python 3.4+).
fix
For new projects or modern Python environments (3.4+), consider using Python's built-in `http.cookies` or a more actively maintained third-party library if specific RFC 6265 strictness is not paramount, or if you require functionality beyond basic parsing/rendering.
affects: All versions (since 2014)
gotchaThe library avoids providing a means to store pickled Python objects in cookie values due to security concerns, a feature present in older `Cookie.py` implementations (e.g., `SmartCookie`).
fix
Do not attempt to store complex Python objects directly as cookie values; serialize them to strings (e.g., JSON) if necessary, or store state server-side using a session ID.
affects: All versions
Upgrade
Version history
2.2.1latest on PyPI · released Sep 27, 2014
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
cookies — pip install cookies · libregistry