A session pass at the Pos Ronda gate, written by the real document.cookie. Set HttpOnly, Secure and SameSite, then see which door is still open. An…
Why it matters
A leaked session token means a hijacked account, in production. One flag left off opens a whole class of attack. Sound auth is not about using a cookie, but setting these three flags right; a missing flag is a hole audits often find.
The key idea
One cookie, three different threats, one flag per door
Common mistakes
A session token kept in localStorage for convenience, then one script bug takes all of itlocalStorage is readable by any script, so one script bug means the token is stolen. Use an HttpOnly cookie so no script can touch it at all.
Setting SameSite=Lax and assuming CSRF is fully handled Lax allows a top-level GET, so if an endpoint changes data through GET (an anti-pattern), CSRF still gets through. Use POST for changes and a CSRF token for sensitive cases.
Setting SameSite=None but the cookie is never stored Modern browsers refuse it outright: None must pair with Secure, or the cookie is dropped without a word.
Try it in this playground
Turn HttpOnly on, see the script get an empty string document.cookie that read the pass now returns empty, for real.
Set SameSite=Lax, hold the cross-site POST The pass skips a cross-site POST, but a GET link still carries it.
See Lax still send via a link Arriving from an outside link (a top-level GET), the user stays signed in: the Lax middle door.
Turn Secure on, keep it off http The pass stops on the plain http road, nothing is sent over the wire.