Secure, HttpOnly and SameSite cookies
Protect login cookies from being stolen over plain HTTP, read by injected scripts, or sent in cross-site attacks.
What it is
Three cookie flags: Secure (HTTPS only), HttpOnly (JavaScript cannot read it), and SameSite (not sent on most cross-site requests).
Why it matters
A stolen session cookie lets an attacker act as the logged-in user without a password.
How to fix it
Raw header
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax
Express (express-session)
app.use(session({ secret: process.env.SESSION_SECRET, cookie: { secure: true, httpOnly: true, sameSite: "lax" }, }));
PHP (php.ini)
session.cookie_secure = 1 session.cookie_httponly = 1 session.cookie_samesite = "Lax"
Does your site have this problem?
Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.