Cookie Header Explained

What the HTTP Cookie header does and when it's used.

Published October 14, 2026

Cookie is a request header in which the browser sends back cookies the server previously set with Set-Cookie.

How it works

It is sent automatically with matching requests, which is why CSRF and cookie-size problems exist.

The Cookie header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
Cookie: sid=abc123; theme=dark
Where Cookie appears.

Practical examples

The header

Cookie: sid=abc123; theme=dark

Set or use it in code

const sid = req.headers.cookie?.split('; ').find(c => c.startsWith('sid='))

Inspect it

curl -sI https://example.com | grep -i 'cookie'

Common mistakes

  • Huge cookies causing 431 errors
  • Putting secrets in readable cookies
  • Forgetting SameSite and Secure flags on the Set-Cookie side

Key takeaways

  • Cookie: Cookie is a request header in which the browser sends back cookies the server previously set with Set-Cookie.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

Can JavaScript read it?

Only cookies not marked HttpOnly, via document.cookie.

Is Cookie case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles