Cookie security flags check: Secure, HttpOnly and SameSite
Every cookie your site sets should carry three flags: Secure (only sent over HTTPS), HttpOnly (JavaScript can't read it) and SameSite=Lax (not sent on most cross-site requests). SiteShield fails a homepage cookie without Secure, warns when only HttpOnly or SameSite is missing, and passes when all cookies have all three (5 of 100 points).
What is Cookie security flags?
Cookies are set with a Set-Cookie response header plus attributes:
- Secure: the browser only sends the cookie over HTTPS.
- HttpOnly: page scripts can't read it through
document.cookie. - SameSite:
LaxorStrictstops the cookie riding along on requests started by other sites;Noneallows it (and requires Secure).
Set-Cookie: PHPSESSID=abc123; path=/Set-Cookie: PHPSESSID=abc123; Path=/; Secure; HttpOnly; SameSite=LaxWhy it matters
Cookies without Secure can leak over HTTP; without HttpOnly, any injected script can steal sessions; without SameSite, other sites can make requests as your logged-in users.
Session cookies are the keys to your customers' accounts. Without Secure, a single http:// request can leak them on public Wi-Fi. Without HttpOnly, one cross-site-scripting bug lets an attacker copy every visitor's session. Without SameSite, other sites can submit forms to yours as the logged-in user (CSRF).
SiteShield maps this check to:
See how these standards fit together in the UAE website security checklist.
How SiteShield grades it
This check, "Cookie security flags", can cost up to 5 points: a fail loses all 5, a warning loses 3. Every scan starts at 100.
| Result | When | Points lost |
|---|---|---|
| Pass | The homepage sets no cookies, or every cookie (up to 20 are checked) has Secure, HttpOnly and SameSite. | 0 |
| Warning | Some cookies are missing HttpOnly and/or SameSite, but all have Secure. | 3 |
| Fail | At least one cookie is missing the Secure flag. | 5 |
SiteShield reads the Set-Cookie headers of the homepage response. Cookies created later by JavaScript (analytics, consent banners) or on other pages aren't seen.
How to check it yourself
List the cookies your homepage sets, or open developer tools → Application → Cookies:
curl -sI https://example.com | grep -i '^set-cookie'
Or run a free SiteShield scan, which checks this and 16 other settings in one go.
How to fix it
The quick version: Set cookies with: Secure; HttpOnly; SameSite=Lax
Your application (best)
Set the flags where the cookie is created. In PHP's php.ini for the session cookie:
session.cookie_secure = 1
session.cookie_httponly = 1
session.cookie_samesite = "Lax"Nginx (reverse proxy)
If Nginx proxies an app you can't change, version 1.19.3+ can add flags to cookies passing through:
proxy_cookie_flags ~ secure httponly samesite=lax;Apache
mod_headers can append flags to every Set-Cookie header. Test it: if the app already sets a flag you'll get duplicates.
Header always edit Set-Cookie ^(.*)$ "$1; Secure; HttpOnly; SameSite=Lax"Cloudflare
Cloudflare's own cookies (such as __cf_bm) already carry the flags. Fix cookies from your origin in the app or web server; Cloudflare can't easily rewrite Set-Cookie attributes on the free plan.
WordPress
WordPress login cookies are already HttpOnly and Secure on HTTPS sites. Front-end cookies usually come from plugins (cache, analytics, chat, cookie banners, WooCommerce sessions). Find the cookie name in the SiteShield report, find the plugin that sets it, and update or reconfigure that plugin.
FAQ
Why is a missing Secure flag a fail but missing HttpOnly only a warning?
A cookie without Secure can be sent over plain HTTP and intercepted, which is always a risk. Some legitimate cookies must be readable by JavaScript (a consent banner's choice, for example), so a missing HttpOnly is a warning to review rather than an automatic failure.
Should I use SameSite=Strict or Lax?
Lax is the usual choice: it blocks cross-site form posts but still sends the cookie when someone follows a link to your site, so they stay logged in. Strict is safer for banking-style apps but logs users out when they arrive from an email link.
Test your Cookie security flags now
Run all 17 checks on your website and email domain in about 30 seconds. Free, no signup, passive checks only.
Rather not do it yourself? Fix it for me starts at AED 750 (about USD 205 by PayPal), quote agreed first. Monitoring re-scans weekly for AED 99/month or AED 990/year.