Creates a new, empty cookie jar.
@eryx/http/CookieJar Module
JSON
A cookie jar that stores cookies and automatically attaches them to matching requests.
local jar = http.CookieJar.new()
-- Make requests with automatic cookie handling
local resp = http.get("http://example.com/login", { cookies = jar })
-- jar now contains any Set-Cookie headers from the response
-- Subsequent requests send matching cookies automatically
local resp2 = http.get("http://example.com/dashboard", { cookies = jar })
Summary
Classes
API Reference
Classes
CookieJar
Properties
CookieJar:parseSetCookie
Stores cookies from a Set-Cookie response header.
Parses the header value and stores the cookie with proper domain and path defaults derived from the request URL. Existing cookies with the same name/domain/path are replaced.
Parameters
The raw Set-Cookie header value.
The host the request was sent to.
The path the request was sent to.
CookieJar:getCookies
Returns all cookies that match the given URL components.
Expired cookies are automatically removed. Only cookies whose domain and path match the request are returned.
Parameters
The request scheme ("http" or "https").
The request host.
The request path.
Returns
Matching cookies.
CookieJar:headerFor
Builds the Cookie header string for a request to the given URL.
Parameters
The request scheme.
The request host.
The request path.
Returns
The Cookie header value, or nil if no cookies match.
CookieJar:count
Returns the number of cookies stored in the jar.
Returns
The cookie count.
CookieJar:clear
Removes all cookies from the jar.