Three attributes on Set-Cookie decide how safe a cookie is: Secure keeps it off plain HTTP, HttpOnly keeps it away from scripts, and SameSite keeps it out of requests other sites trigger. A session cookie should carry all three — and should not rely on browser defaults, which differ.
| Defined in | RFC 6265, and the RFC 6265bis revision in final review |
| SameSite missing | Chrome and Edge treat it as Lax; Firefox and Safari do not |
| SameSite=None | Needs Secure, or the cookie is ignored |
| Strongest form | The __Host- prefix |
Check cookie flags on your site
Enter a domain: we fetch its homepage and read every security header, this one first.
What it does
Secure sends the cookie only over HTTPS, so it cannot be read off a plain HTTP connection. HttpOnly hides it from document.cookie, so a script injected into the page cannot steal it — the browser still sends it with requests. SameSite decides whether it goes with requests started by other sites: Strict never, Lax only on top-level navigation such as following a link, None always.
Chrome and Edge treat a cookie without SameSite as Lax, but Firefox and Safari send it with every cross-site request — so a cookie that relies on the default is protected in some browsers and not others. Set it explicitly.
Directives and values
| Directive or value | What it does |
|---|---|
Secure | Sent over HTTPS only. Protects confidentiality, not integrity. |
HttpOnly | Not readable by JavaScript; still sent with fetch() and XHR requests. |
SameSite=Strict | Only on requests from your own site. |
SameSite=Lax | Also on top-level navigation from other sites using a safe method such as GET. |
SameSite=None | On every request — must be paired with Secure. |
__Host- prefix | The cookie must be Secure, have Path=/ and no Domain, which locks it to one host. |
What a session cookie should look like
Set-Cookie: __Host-SessionID=<value>; Secure; HttpOnly; SameSite=Strict; Path=/
That is OWASP’s example. SameSite=Lax is the practical choice when people arrive logged in from links on other sites; SameSite is a second layer against cross-site request forgery, not a replacement for CSRF tokens.
How to set them
Cookie flags are set by whatever creates the cookie — usually the application or its framework, which has an option for each flag. In PHP:
PHP
setcookie( 'name', $value, [
'secure' => true,
'httponly' => true,
'samesite' => 'Lax',
'path' => '/',
] );
Common mistakes
- SameSite=None without Secure — the browser ignores the cookie.
- Relying on the Lax default, which Firefox and Safari do not apply.
- A __Host- cookie with a Domain attribute or without Path=/ — it is rejected.
- Assuming Secure protects a cookie from being overwritten: it keeps it private, not tamper-proof.
What we recommend
Give every cookie Secure and an explicit SameSite, and every session or login cookie HttpOnly too, ideally with the __Host- prefix. Our check reads the cookies the homepage sets; log-in pages and carts often set more — check those in the browser’s developer tools.
Questions
Why does my scanner flag cookies I did not set?
Plugins, analytics and chat widgets set their own. Our check lists each cookie by name with the flags it lacks, so you can see which part of the site sets it.
Sources
Checked on 25 September 2026 against these official sources:
- RFC 6265: HTTP State Management Mechanism — rfc-editor.org
- Cookies: HTTP State Management Mechanism (draft-ietf-httpbis-rfc6265bis-22) — ietf.org
- Set-Cookie header — developer.mozilla.org
- Session Management — cheatsheetseries.owasp.org
- SameSite Updates — chromium.org