Understanding Secure, HttpOnly and SameSite Cookie Flags

A cookie flag is a small instruction your website attaches to a cookie that tells the browser how to handle it, and the three that matter most for security are Secure, HttpOnly and SameSite. If our free scan flagged one of them as missing, it means a cookie your site sets is not carrying that instruction, so the browser is treating it more loosely than it could be.

Explainer5 min read

None of the three flags is complicated once you see what each one actually stops. Secure keeps a cookie off plain HTTP, HttpOnly hides it from JavaScript, and SameSite limits when the cookie is sent along with requests that come from other sites. This page explains all three in plain English and, importantly, why a missing flag on a login or session cookie is a bigger deal than the same warning on an analytics cookie.

What the Secure flag does

The Secure flag tells the browser to send a cookie only over an encrypted HTTPS connection, never over plain HTTP. Without it, if any part of your site is ever reached over http:// (an old link, a hardcoded image, a redirect that fires a moment too late) the cookie can travel in clear text where anyone on the same network can read it.

For a session or login cookie this is the difference between a value that stays private and one that could be lifted from public Wi-Fi. Setting Secure is low-risk on a site that already runs fully on HTTPS, because every legitimate request is encrypted anyway, so the flag simply closes the plain-HTTP gap.

What the HttpOnly flag does

HttpOnly tells the browser that a cookie must not be readable by JavaScript running on the page. Normal scripts can reach cookies through document.cookie, and so can malicious script injected through a cross-site scripting flaw. If your session cookie is HttpOnly, that injected script cannot simply read the cookie and send it off to an attacker.

This is the flag that most directly protects a logged-in session. It does not fix the underlying script-injection problem, but it removes the easiest way to steal a session token, which is why a missing HttpOnly on an authentication cookie is worth acting on quickly.

What the SameSite flag does

SameSite controls whether a cookie is sent when a request to your site is triggered from a different site. With SameSite set to Lax or Strict, a form or script on someone else's page cannot quietly make the browser include your cookie in a request to your domain, which is the mechanism behind cross-site request forgery.

Lax is a sensible default for most sites: the cookie still rides along with normal top-level navigation, so users stay logged in when they click through to you, but it is held back on the sneaky cross-site background requests. Strict is tighter and occasionally too tight for links coming from email or other sites, so it suits high-value cookies where a small login friction is acceptable.

Free, instant, no account

See your site's security grade in seconds.

Free, instant, and no account needed to see your grade.

Scan my site free

Plain-English A to E grade in about 10 seconds. No account needed to see it.

Not every cookie carries the same risk. A cookie that holds your session (the thing that keeps a user logged in) is a key to an account, so Secure, HttpOnly and a sensible SameSite value all matter for it. If that cookie leaks or gets sent where it should not, someone can act as that user.

An analytics or preference cookie, by contrast, usually holds a random visitor ID or a setting like a chosen language. A missing flag there is untidy and still worth fixing, but it is not handing anyone the keys to an account. When you read a cookie-flags warning, look first at what the cookie is for: session and authentication cookies are the ones to prioritise.

What our scan can and cannot see

The free EB Security scan reads the flags on cookies your site sets for an anonymous visitor, the ones handed out on the public pages before anyone logs in. It reports whether each of those cookies carries Secure, HttpOnly and SameSite, and explains any that are missing.

It cannot see cookies that are only set after a user logs in, because it never logs in, and it does not read or audit your session-handling code. So treat a clean result as good news for your public cookies, not as a full review of your authentication. If your login flow sets its own session cookie, check that one directly in your platform or with your developer.

Secure keeps cookies off plain HTTP, HttpOnly hides them from scripts, and SameSite limits cross-site sending. All three matter most on session and login cookies, so fix those first and remember the scan only sees the cookies your site sets before anyone logs in.

Common questions

Is it safe to add the Secure flag to all my cookies?
If your site runs entirely on HTTPS, yes. Every legitimate request is already encrypted, so adding Secure only blocks the cookie from travelling over plain HTTP, which you do not want anyway. The one thing to check is that you are not relying on any part of the site still being served over http://.
Will HttpOnly break my analytics or front-end scripts?
It can, if a script genuinely needs to read that specific cookie from JavaScript, which is sometimes the case for analytics or personalisation cookies. Session and login cookies almost never need to be read by scripts, so HttpOnly is safe and recommended for those. Apply it per cookie rather than blanket-on.
Should I use SameSite Lax or Strict?
Lax is the sensible default for most sites and is what browsers now assume when no value is set. It keeps users logged in when they follow a link to you while still blocking the risky cross-site background requests. Strict is tighter and can log people out when they arrive from email or another site, so reserve it for high-value cookies.
The scan says my cookies are fine. Does that mean my login is secure?
Not on its own. The scan only reads cookies your site sets for an anonymous visitor, before anyone logs in. It does not log in or review your session-handling code, so a clean result covers your public cookies but not the session cookie your login flow issues. Check that one directly.
Where do I actually change these cookie flags?
It depends on your platform. In WordPress, cookie flags for core and plugin cookies are usually handled in code or by a security plugin; on a custom app they are set wherever your code creates the cookie or session. Your developer or hosting support can set Secure, HttpOnly and SameSite in the relevant configuration.

How safe is your website?

A free A to E grade in about 10 seconds. No account needed.

Check my site