Skip to content

Cookie settings

SameSite attribute

The SameSite attribute controls whether a cookie is sent with requests from other sites; Lax is the safe default for most cookies.

Scanetra rating: LowCheck CKE-03

Why it matters

SameSite=None without Secure is silently dropped by browsers, so features that depend on the cookie, like embedded widgets or sign-in, stop working. Lax or Strict also helps against cross-site request forgery.

What Scanetra looks for

  • Cookies with SameSite=None but no Secure, which browsers reject.
  • Session cookies with no SameSite attribute (a note: browsers default to Lax).

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=Lax

PHP

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 = True

nginx (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

Each cookie has SameSite=Lax or Strict, or SameSite=None together with Secure. Then scan again.

Check your own site

A free scan tells you whether your site passes this check, and the 24 others.

Scan a website