Cookie settings
Secure attribute
The Secure attribute tells browsers to send a cookie only over HTTPS, so it never travels unencrypted.
Why it matters
A cookie without Secure can be sent over HTTP, for example on a visitor's first plain-HTTP request. Someone on the network who copies a session cookie can act as the signed-in visitor.
What Scanetra looks for
- Cookies set without Secure.
- Session cookies (by a framework's default name) set without Secure, which is more serious.
It reads only your homepage's public response. How a scan works
How to fix it
The header
What a well-set session cookie looks like:
Set-Cookie: session=…; Path=/; Secure; HttpOnly; SameSite=LaxPHP
In php.ini, for PHP's own session cookie:
session.cookie_secure = 1
session.cookie_httponly = 1
session.cookie_samesite = "Lax"Express
res.cookie("session", value, { secure: true, httpOnly: true, sameSite: "lax" });Django
In settings.py:
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = "Lax"
CSRF_COOKIE_SECURE = Truenginx (in front of an app)
When you can't change the app, nginx 1.19.3 or later can add the flags to cookies it passes on:
proxy_cookie_flags ~ secure httponly samesite=lax;Replace example.com with your own domain, and test changes on a staging copy first where you can.
Check that it worked
The Set-Cookie header for each cookie includes Secure. Then scan again.
Check your own site
A free scan tells you whether your site passes this check, and the 24 others.