Cookie security flags (Secure, HttpOnly, SameSite)

What the Secure, HttpOnly and SameSite cookie flags do, which cookies need them, and how to set them on your server or framework.

What AuditX checks

The scan reads every Set-Cookie header on the response to your homepage. On an https page, a cookie without the Secure flag is flagged. For cookies that look like login or session cookies (judged by a name such as session, sid, auth, token or login, or a long random-looking value), a missing HttpOnly or SameSite attribute is flagged too. Anti-forgery cookies such as XSRF-TOKEN, cookie-consent records, analytics visitor IDs such as the Adobe ones, bot-check cookies set by a CDN (Akamai bm_s and _abck, Cloudflare __cf_bm, Imperva, DataDome, PerimeterX) and harmless preference cookies are not held to the HttpOnly and SameSite rule. If every cookie has the flags it needs, the check passes. It fails when a session-like cookie lacks Secure, and warns for any other missing flag. One exception: a cookie that is not session-like and only lacks Secure is informational when the response sends HSTS with a max-age above zero, because the browser then never talks plain http to that host. That holds for a cookie without a Domain attribute, or for any cookie when HSTS also has includeSubDomains. If the homepage sets no cookies the result is informational. Cookies set later by JavaScript or on other pages are not seen.

Why it matters

Secure keeps a cookie off unencrypted connections, where someone on the same network could read it. HttpOnly hides it from page scripts, so an injected script cannot steal a login session. SameSite stops other sites from sending it along with requests they trigger, which blocks most cross-site request forgery.

A stolen session cookie lets someone act as the logged-in user without knowing the password, so these flags matter most on cookies that prove who someone is.

How to fix it

  1. Add Secure to every cookie your site sets over https.
  2. Add HttpOnly and SameSite=Lax (or Strict) to session and login cookies. Leave HttpOnly off cookies your own scripts need to read.
  3. Most frameworks and CMS platforms have a setting for this, such as session.cookie_secure and session.cookie_httponly in PHP. Check that setting before editing headers by hand.
  4. Third-party cookies you cannot change, from an embedded widget for example, are set by that vendor. Ask them or drop the widget.
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax

Does your site pass this check? A free scan runs it with every other check and shows the result in about a minute.

Scan my site

Sources

Related checks

Last reviewed 2026-11-13.