Use this when setting cookie security attributes.
Cookies
Cookies store session and state data in the browser. Mark session cookies Secure, HttpOnly and SameSite, scope them to the right domain and path, and give them sensible lifetimes.
server Set-Cookie → browser stores with flags → sent per rules
Context & applicabilityCommon mistakes · platform/version boundaries
- Session cookies without
HttpOnly, readable by XSS. Domain=.example.comsharing cookies with every subdomain, including less trusted ones.- Sensitive data stored in cookies in plain text.
- Very long-lived "remember me" cookies without rotation or server-side revocation.
Operational reference
Fast context before you go deeper.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Set Secure, HttpOnly and SameSite on session cookies.
- Scope domain and path narrowly.
- Use sensible lifetimes.
curl -sI https://<site> | grep -i set-cookie— cookie flags- Secure, HttpOnly, SameSite on session cookies — flags
- __Host- prefix — scoping
ReferenceWhy it matters1 section · depth on demand
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Cookies store small pieces of data in the browser and are sent automatically with requests to the matching site — which is why they carry sessions and why their attributes matter for security.
| Attribute | Effect |
|---|---|
Secure | Only sent over HTTPS |
HttpOnly | Not readable by JavaScript (limits XSS theft) |
SameSite=Lax/Strict | Not sent on most cross-site requests (CSRF defence) |
Domain | Which hosts receive it (omit to restrict to exact host) |
Path | URL path scope |
Max-Age/Expires | Lifetime; omit for session cookies |
__Host- prefix | Enforces Secure, no Domain, Path=/ |
Set-Cookie: __Host-session=…; Secure; HttpOnly; SameSite=Lax; Path=/
Documented example, not captured output. Inspect cookies in the browser developer tools (Application/Storage tab).
Cookie attributes
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Web Security → Cookies. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://owasp.org/www-project-application-security-verification-standard/ · confidence 94%