Cookie: what the browser sends back
Cookie carries the name and value pairs a browser has stored for the target host and path. Attributes such as Secure and SameSite are never sent back.
At a glance
- Direction
- Request only. The server sets cookies with Set-Cookie.
- Defined in
- RFC 6265, with RFC 6265bis in progress
- When absent
- The server has no stored state for this client, so treat the request as belonging to a new visitor.
- Format
- One header with pairs separated by a semicolon and a space: a=1; b=2
- Never sent back
- Domain, Path, Expires, Secure, HttpOnly, SameSite. Only names and values travel.
- Ordering
- Longer paths first. Two cookies with the same name are both sent.
- Practical limits
- Around 4096 bytes per cookie, and a per domain count limit in every browser
In detail
Everything the server said about a cookie is stripped before it comes back. The request carries names and values and nothing else, so a server cannot tell whether an arriving cookie was marked Secure, which host set it, or when it will expire. Any of that you need has to be encoded in the value or held server side.
Two cookies with the same name can arrive together, set by different domains or paths, and the header gives no way to tell them apart beyond ordering. Cookie parsing libraries usually keep the first or the last, which means an attacker who can set a cookie on a sibling subdomain may be able to shadow the one your application reads.
Size matters more than it looks. Every cookie for a matching host is attached to every matching request, including images and scripts, so a few kilobytes of accumulated cookies is a few kilobytes added to hundreds of requests. Serving static assets from a cookieless host is an old technique that still works for exactly this reason.
Because the browser sends whatever matches the host and path, the presence of a cookie proves nothing about who is making the request. Cross-site request forgery works precisely because the browser attaches cookies to a request initiated by someone else's page, which is why session cookies need SameSite and why unsafe methods need an origin check as well.
Examples
GET /account HTTP/1.1
Host: example.com
Cookie: session=8f2b91ac; theme=dark; consent=grantedcurl -s -H 'Cookie: session=8f2b91ac' https://example.com/accountThings that catch people out
- Attributes never come back, so a server cannot verify that the cookie it received was the Secure one it originally set.
- Duplicate names arrive together with no reliable way to distinguish them, which is the basis of cookie shadowing from a sibling subdomain.
- Every cookie is attached to every matching request, so a large cookie is a tax on every asset served from the same host.
Try it: HTTP Headers Checker
Check a live URL or paste headers you already have. It grades six security headers from A+ to F and lists every other header the response returned.
HTTP Headers Checker
LOCAL · Browser-OnlyView HTTP response headers for any URL
Enter any website URL to fetch and analyze its HTTP response headers. We'll automatically add https:// if needed.
Why Check Security Headers?
Security headers protect your website against common attacks like XSS, clickjacking, and MIME sniffing. They're set by your web server and cost nothing to implement. Missing security headers are one of the most common findings in security audits.
Related HTTP headers
All http headers →Set-Cookie: attributes, SameSite and cookie prefixes
Every Set-Cookie attribute explained, why SameSite=None needs Secure, what the __Host- prefix guarantees, and how Max-Age and Expires interact.
Access-Control-Allow-Credentials: cookies across origins
What credentials mode means, the three wildcards it disables, what the client must also do, and why this header needs an exact origin in the response.
Clear-Site-Data: wiping browser state on logout
How Clear-Site-Data clears cookies, storage and caches for your origin, which directives are safe on a logout response, and where support is uneven.
Origin: where a request was initiated from
When browsers send Origin, why it is only scheme, host and port, when the value is null, and how to use it for cross-site request forgery defence.
Host: which site the request is for
Why Host is mandatory in HTTP/1.1, how it maps to the authority in HTTP/2 and HTTP/3, and why trusting it to build URLs creates a real vulnerability.
Location: where the client should go next
How Location works on each 3xx status, why it also appears on a 201 Created, whether relative URLs are allowed, and how to avoid an open redirect.
Tools for this
- HTTP Request Builder Free online HTTP request builder - build and test HTTP requests with custom headers and body
- HTTP Headers Checker Free online HTTP headers checker - view HTTP response headers for any URL