A cookie is a small name-value pair that a server sets in a browser using the Set-Cookie header. The browser sends it back with each matching request, letting the site recognize a returning visitor.
Why it matters
Because HTTP is stateless, cookies are how sites keep you logged in, remember a cart or store a language choice. They are also used for analytics and advertising, which is why privacy laws and consent banners focus on them. Their attributes decide whether they are safe.
Many regions require informing visitors and, for non-essential cookies, obtaining consent first, so know which cookies your site sets and why.
Example
Set-Cookie: session_id=abc123; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=3600
Secure restricts it to HTTPS, HttpOnly hides it from JavaScript, and SameSite limits cross-site sending.
Common mistakes
- Omitting
SecureandHttpOnlyon session cookies. - Storing sensitive data directly in a cookie instead of a server-side session.
- Setting cookies on a broad domain so every subdomain receives them unnecessarily.
Related
- Session
- HTTPS
- Incognito mode
- Guide: cookie flags
- Tool: Cookie checker
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.