Cookie jar limits and optional custom domain matcher
Total number of cookies currently stored in the jar.
Destroy the jar — clears the periodic cleanup timer. Call this when the jar is no longer needed to prevent memory leaks.
Set a cookie per RFC 6265 §5.3.
Rejects cookies that exceed size limits, fail domain/path validation, violate prefix rules, or would be immediately expired (treats those as deletes).
Raw Set-Cookie header value (e.g. "session=abc; Path=/; Secure")
URL the cookie was received from + SameSite context
true if the cookie was stored, false if rejected
Retrieve matching cookies per RFC 6265 §5.4.
Filters by domain, path, secure/httpOnly flags, and SameSite context. Results are sorted by longest path first, then oldest creation time. Updates lastAccessed on returned cookies.
URL, protocol context, and SameSite context
Array of matching Cookie objects (direct references into storage)
Get a Cookie header string for a request.
URL and request context
"name=value; name=value" string suitable for a Cookie header
Get all cookies for a specific domain.
The domain to get cookies for (will be canonicalized)
Array of cookies that would be sent to this domain
Process Set-Cookie headers from an HTTP response. Extracts all Set-Cookie values and calls setCookie() for each.
Response headers (Headers object or plain record)
URL and SameSite context for all cookies
Remove a specific cookie by domain, path, and name.
Domain the cookie was stored under
Cookie path
Cookie name
true if a cookie was removed
Remove every cookie from the jar.
Remove all expired cookies from the jar.
Number of cookies removed
Remove all session cookies (cookies with no expiry / Infinity).
Number of cookies removed
Remove all cookies for a domain and its subdomains.
Domain to clear (e.g., "example.com" clears sub.example.com too)
Number of cookies removed
Remove all cookies that would be sent to a given URL.
Full URL whose hostname cookies should be cleared
Number of cookies removed
Serialize all non-expired cookies to a JSON-compatible array.
Session cookies (Infinity) are stored with expires: null.
Array of serialized cookies
Get a pretty-printed JSON string of all cookies.
Formatted JSON string
StaticfromDeserialize cookies from JSON and create a new CookieJar. Expired cookies in the input are silently skipped.
Array of serialized cookies or a JSON string
A new CookieJar populated with the deserialized cookies
Return a snapshot of all cookies (copies, not references to internal storage).
Array of cloned Cookie objects
Return all cookies for a given domain (exact match + subdomains).
Domain to query (e.g., "example.com")
Array of cloned Cookie objects for matching domains
RFC 6265 §5.3 + §5.4 cookie jar implementation.
Stores cookies in a three-level map (domain → path → name) with:
Example