Skip to content
Glossary

Cookie jar

A cookie jar is the store a client keeps of the cookies it has received, keyed by domain and path, and replayed on later requests that match.

A cookie jar is the store a client keeps of the cookies it has received, keyed by domain and path, and replayed on later requests that match. It is the mechanism that turns stateless HTTP requests into something a server can recognise as a continuing session.

#What the jar holds

Each entry carries a name and value plus the attributes that decide when it is sent back: the domain, the path, an expiry, and flags marking it as secure or inaccessible to scripts. A cookie is returned only when all of those match the outgoing request, which is why a jar shared across sites is not as promiscuous as it sounds.

RFC 6265 sets minimum capacities that user agents should support: at least 4096 bytes per cookie, at least 50 cookies per domain, and at least 3000 in total. Real clients differ above those floors.

#Why it matters more than the exit address

A session identifier in a jar is a far stronger identity than an address. Reusing one jar across a rotating proxy tells the target that a single client is moving between addresses, which is more distinctive than staying on one address would have been. Rotation and shared state work against each other.

The rule that follows is simple: one jar per identity, created and destroyed with the identity, never shared between them. If you want a sticky session, pin the jar and the exit together.

#Handling it explicitly

curl -c jar.txt -b jar.txt -x http://gateway.example:8000 https://example.com/

Writing the jar to a named file per identity makes the coupling visible and reviewable. Any client that keeps a default jar in a process-wide singleton will merge identities the moment you run two in one process, and the mistake produces no error.

#Commonly confused with

A session is the server’s notion of a continuing interaction; the jar is the client’s storage that sustains it. Clearing a jar does not end a session that is also tracked by fingerprinting or by an address, and a headless browser keeps state in several other places besides cookies.

Frequently asked questions

Should each proxy identity have its own cookie jar?
Yes. A session identifier reused across exit addresses tells the target that one client is moving between them, which is more distinctive than never rotating. Create the jar with the identity, destroy it with the identity, and never let two identities share a process-wide default jar.
What are the minimum cookie limits a client must support?
RFC 6265 states that user agents should support at least 4096 bytes per cookie, at least 50 cookies per domain and at least 3000 cookies in total. These are floors rather than actual limits, and real clients vary above them, so do not design against the minimum figures.
Does clearing cookies reset my identity?
It removes one signal and leaves the rest in place. The exit address, the TLS handshake, HTTP/2 connection behaviour, browser storage other than cookies, and script-visible properties are all untouched by emptying a jar. A target correlating on any of those will link the new jar to the old one on the first request.

Sources

  1. RFC 6265: HTTP state management, cookie attributes, matching rules and minimum capacities

Related terms