BreachHunter
Pricing Blog Log inSign up
● thermal huntscan engines onlineassessment only — no exploits
  1. Home
  2. Blog
  3. Cookie Flags Explained: Secure, HttpOnly and SameSite

Guides · ← All guides

Cookie Flags Explained: Secure, HttpOnly and SameSite

Published: November 14, 2026 · Last reviewed: November 14, 2026 · 8 min read

By the Ingenious AI team

The short answer: Three flags decide how exposed your session cookies are. Secure means the cookie travels only over HTTPS. HttpOnly means page scripts cannot read it, so an XSS hole cannot simply steal the session. SameSite means other sites cannot ride the cookie on cross-site requests, blunting CSRF. BreachHunter's web audit checks the flags on the cookies your site sets — a session cookie missing HttpOnly or Secure is flagged in the report with the exact Set-Cookie line as evidence.

Run a free BreachHunter assessment on your site →

Cookies are how your site remembers who is logged in — which makes the session cookie the single most valuable string your server hands out. Attackers do not need your password database if they can lift one admin's session cookie. The three flags are how you make that string hard to steal, hard to leak, and hard to abuse from another site.

This guide explains each flag against the attack it defeats, the scanner's separate checks for each (they are filed individually in the code, not as one vague “cookie hygiene” note), and the compatibility notes — SameSite modes, legacy browsers — that decide how strict you can go.

Secure and HttpOnly: protecting the cookie at rest and in transit

A cookie without Secure will happily travel over a plain-HTTP request — the downgrade scenario HSTS exists to prevent — exposing the session to anyone sharing the network. The check in the scanner's cookie function is blunt: a session cookie set without the Secure flag gets its own finding, because the fix is a checkbox in every framework.

HttpOnly defends a different moment: after an attacker finds any script-injection point, their first move is document.cookie — reading every cookie the page can see and shipping the session id to themselves. An HttpOnly cookie is invisible to that API. The browser still sends it with requests; scripts simply cannot read it. Together the two flags mean the session can neither be sniffed off the wire nor lifted out of the page — the two cheapest session-theft routes both close.

SameSite: the flag that decides whose requests carry your cookie

Cross-site request forgery works because browsers attach your cookies to requests other sites trigger. SameSite=Lax — the modern browser default when no attribute is given — already withholds the cookie from cross-site POSTs, which kills most classic CSRF. SameSite=Strict goes further and withholds it on cross-site top-level navigation too, at the cost of users arriving from email links appearing logged out until they navigate once.

The assessment angle is explicitness: a cookie that relies on browser defaults behaves differently across clients and ages badly as defaults evolve. Setting the attribute deliberately — Lax for general sessions, Strict for admin surfaces, and None; Secure only for cookies that genuinely must cross sites, like embedded widgets — is what a reviewer wants to see in the Set-Cookie evidence line. Pair this with the header work in the security headers guide: flags and headers are audited in the same phase and usually fixed in the same change.

Worked example: bluepinebakery.example

Bluepine Bakery's online ordering site set its session cookie with no flags at all — the assessment printed the evidence exactly as the server sent it:

Set-Cookie: session=8f3ka91md72; Path=/; Max-Age=1209600
(no Secure, no HttpOnly, no SameSite)

One configuration change in the bakery's framework produced the corrected line — Set-Cookie: session=…; Path=/; Secure; HttpOnly; SameSite=Lax — and the retest closed both flag findings. Nothing about the ordering flow changed for customers; what changed is that the session id stopped being readable by any script on the page and stopped travelling over the one remaining HTTP redirect the site still served. For a shop whose admin session can issue refunds, that was the highest-value ten minutes in its whole report.

The five actions to take

Getting every session cookie fully flagged:

  1. List the cookies your site sets (browser dev tools, Application tab) and mark which are session or authentication cookies.
  2. Set Secure on every cookie — your site is HTTPS; there is no production reason for a cookie to travel over HTTP.
  3. Set HttpOnly on session cookies; audit any script that claims to need cookie access and move that state server-side.
  4. Set SameSite=Lax as the baseline, Strict on admin cookies, and None only with Secure for true cross-site embeds.
  5. Re-scan and read the Set-Cookie evidence lines in the new report to confirm every flag landed.

Run a free BreachHunter assessment on your site →

Frequently asked questions

What does the HttpOnly flag actually prevent?

It prevents page scripts from reading the cookie via document.cookie. An attacker with an XSS foothold can still ride the victim's browser, but cannot exfiltrate the session id to use from their own machine — a much smaller and shorter-lived compromise.

Is SameSite=Lax enough, or do I need Strict?

Lax is the right default for most sites: it blocks cross-site POST cookie sending, which defeats classic CSRF, while keeping normal link-following behavior. Strict suits admin panels and banking-style surfaces where arriving logged-out from an external link is acceptable.

My framework sets these flags automatically. Why did I get the finding?

Usually because one cookie is set outside the framework's session handling — an analytics, remember-me or load-balancer cookie — or because an older configuration overrode the defaults. The report's evidence line names the exact cookie to chase.

Do cookie flags replace CSRF tokens?

No. SameSite is a strong layer, but tokens remain the deliberate defense for state-changing forms, especially where SameSite=None cookies or same-site subdomains are involved. Assessments check for flags; a pentest will check for tokens.

What about cookie prefixes like __Host-?

The __Host- prefix is a useful hardening step: browsers only accept such cookies when they are Secure, Path=/, and set without a Domain attribute. It is optional polish on top of the three flags, not a substitute for them.

Checking your own cookies in two minutes

You do not need a scanner for a first look. Open your site in a browser, open developer tools, and find the cookies view under Application or Storage: every cookie lists its Secure, HttpOnly and SameSite attributes in plain columns. A session cookie with three empty columns is the finding, photographed.

Prefer the terminal? curl -sI https://yoursite.example/login prints the raw Set-Cookie headers exactly as the server sends them. Read them the way an assessor does: the flags are either in that line or they do not exist, whatever the framework documentation promised.

Sources

The primary sources behind this guide — the documents we check our own work against:

  • RFC 6265 (2011) — the HTTP cookie specification that defines Secure and HttpOnly.
  • MDN — Using HTTP cookies (2025) — SameSite behaviour and cookie prefixes as browsers enforce them.
  • OWASP Session Management Cheat Sheet (2024) — cookie attribute guidance for session cookies.
Share this: X · Facebook · LinkedIn · WhatsApp

Related guides

  • Website Security Test: What It Checks, What It Misses, and How to Read Yours · 9 min read
  • Website Security Cheat Sheet: Headers, TLS, Cookies and Exposed Files · 7 min read
  • What a Website Security Assessment Actually Tests · 10 min read
  • TLS/SSL Basics: What Your Certificate Says About Your Site · 8 min read
  • Common Website Misconfigurations (and How to Fix Them) · 11 min read
  • Reading Your First Pentest Report: From Score to Action · 9 min read
  • Deleted ≠ Gone: What the Wayback Machine Keeps After You Delete Your Secrets · 9 min read
  • SQL Injection in Plain English: How One Login Box Can Read Your Database · 9 min read
  • What Does a Website Security Scan Check? · 8 min read
  • Exposed .git Directory: What It Leaks and How to Check · 7 min read
  • Security Headers Missing? What Each Header Stops · 7 min read
  • How Much Does a Penetration Test Cost in 2026? · 7 min read
  • Website Security Checklist for Small Teams (60-second self-check) · 6 min read
  • Reading Your Scan Results: Which Findings Fix First? · 7 min read
  • Content-Security-Policy Missing: What CSP Does and How to Add It Safely · 8 min read
  • HSTS Missing: What Strict-Transport-Security Prevents · 7 min read
  • Clickjacking and X-Frame-Options: How Framing Attacks Work · 7 min read
  • Exposed .env File: What Leaks, What Attackers Do Next, What You Do First · 8 min read
  • Directory Listing Enabled: What It Shows Attackers and How to Disable It · 7 min read
  • Mixed Content: Why Your HTTPS Page Still Loads Insecure Resources · 7 min read
  • Expired SSL Certificate: What Breaks, Why Renewal Fails, and How to Catch It Early · 7 min read
  • TLS 1.0 and 1.1 Still Enabled: Why Old Protocols Show Up as a Finding · 7 min read
  • Open Ports on a Web Server: Which Ones Should Never Face the Internet · 8 min read
  • No SPF or DMARC Record: How Missing Email Auth Exposes Your Website · 7 min read
  • Subdomain Takeover: How a Dangling DNS Record Lets Attackers Claim Your Name · 7 min read
  • Forgotten Subdomains: The Staging Site You Forgot Is Still Public · 7 min read
  • WordPress Security Scan: The Exposures an Assessment Finds on WordPress Sites · 8 min read
  • Exposed Backup Files: .bak, .old and .zip Files Sitting in Your Web Root · 7 min read
  • phpinfo() in Production: The Diagnostic Page That Maps Your Server for Attackers · 7 min read
  • Server Version Banners: Why Your Headers Point Attackers to the Right Exploit · 7 min read
  • End-of-Life Software: Running a Server Stack Nobody Patches Anymore · 7 min read
  • CORS Misconfiguration: When Cross-Origin Sharing Opens Your Data to Any Site · 7 min read
  • Open Redirect Vulnerability: How Your Own Domain Sends Visitors to a Phishing Page · 7 min read
  • Dangerous HTTP Methods: What TRACE, PUT and DELETE Should Never Answer · 7 min read
  • Host Header Injection: Poisoned Reset Links and Cache Attacks Explained · 7 min read
  • What Is security.txt? The Small File That Lets Researchers Reach You · 6 min read
  • Admin Panel Exposed to the Internet: What an Assessment Flags and Why · 7 min read
  • phpMyAdmin Exposed: Why This Database Door Is a Prime Brute-Force Target · 7 min read
  • Spring Boot Actuator Exposed: Environment Dumps, Heap Leaks and Shutdown Endpoints · 7 min read
  • Debug Console in Production: The Finding That Can Become Code Execution · 7 min read
  • Exposed AWS Credentials File: The /.aws/credentials Finding, Explained · 7 min read
  • Referrer-Policy and Permissions-Policy: The Two Quiet Headers You Are Probably Missing · 6 min read
  • Exposed package.json: Your Dependency List Is a Recon Gift · 6 min read
  • DNS Zone Transfer Open (AXFR): Handing Out Your Entire DNS Map · 6 min read
  • Certificate Name Mismatch: Why the Cert Does Not Match Your Domain · 6 min read
  • Website Security Assessments for Agencies: Checking Every Client Site Without a Security Team · 8 min read
  • SaaS Security Questionnaires: What Buyers Check About Your Website First · 8 min read
  • Ecommerce Website Security: The Exposures That Put Your Checkout at Risk · 8 min read
  • Small Business Website Security: The Checks That Matter at Your Size · 7 min read
  • How to Prepare for a Website Security Assessment (and Read the Report Calmly) · 7 min read
  • Vulnerability Severity Explained: What Critical, High, Medium and Low Actually Mean · 7 min read
  • Retest After Fixes: How to Prove a Security Finding Is Actually Closed · 7 min read
  • Security Assessment vs Vulnerability Scan vs Pentest: What Is the Difference? · 7 min read
  • How Long Does a Website Security Scan Take? · 6 min read
  • Website Security Drift: Why Last Month's Clean Scan Is Already Out of Date · 7 min read
  • WordPress Site Keeps Getting Hacked After Cleanup · 8 min read
  • Google Blacklist Removal: Getting the Red Warning Off Your Site · 8 min read
  • VirusTotal Flagged My Site: How to Clear a False Positive · 8 min read

Related from the Ingenious AI suite

  • Ingenious AI — the full suite of security and compliance tools
  • DomainGuard — domain impersonation and typosquat defense
  • See BreachHunter pricing →
BreachHunter · by Ingenious AI · read-only security assessment — scan only targets you own or are authorized to test
About · Contact · Blog · vs Intruder · Privacy · Terms · Security · Threats · Nextcloud Check · Verify Evidence · Help · Redeem
More from Ingenious AI:
DisclosureGuard — AI disclosure compliance · Vibe-Code Audit — AI code security scanner · Rogue-Agent Defense — AI agent firewall · ChatBreaker — AI chatbot red-teaming · ModelMinder — AI model deprecation radar · TermsWatch — AI vendor terms monitor · Agent Flight Recorder — tamper-evident agent audit trails · Agent Auth Gateway — agent credentials & kill switch · DomainGuard — domain impersonation defense · Agent Passport — Know-Your-Agent registry · AgentGate — agent policy publisher · AgentBlock — AI agent & crawler access control · BoundaryVault — agent log forensics · Agentic Receipts — verifiable agent payment receipts · EvalEgress — eval-to-production exposure scan · HomeShield MCP — home AI server exposure check · WireWatch — payment verification ceremony · ADMT Notice Kit — AI decision notice compliance · DueLadder — human-approved invoice chasing · Agent-Ready Store Audit — can AI agents buy from your store · ContentCraft AI — content operations · AgentReady — agent-readiness checks · AI Audit Exchange — AI audit exchange · CallbackShield — callback & webhook protection · CompanionGuard — AI companion safety guardrails · CRAClock — EU Cyber Resilience Act deadline clock · EInvoice Translator — e-invoice format translator · GEOFixer — geo & local listing fixes · MandateGuard — agent spending mandates · OutcomeMeter — AI outcome measurement · ProvenanceGuard — content provenance checks · ReviewDesk — review response desk · ReviewProof — verified review evidence · TakedownCoop — coordinated phishing takedowns · TrustGate — trust & safety gating · BreachHunter — website penetration testing · All 36 platforms — the Ingenious AI portfolio

We use cookies. Necessary cookies keep the site working. With your permission we also use analytics cookies (to understand usage) and marketing cookies (for ads). Read our privacy policy.

NecessaryRequired for login, security and core features. Always on.
AnalyticsHelps us understand which pages are useful.
MarketingUsed for advertising and measuring ad performance.

    No match. Try “pricing”, “php2shell” or “contact” — or press Esc to close.

    ↑↓ navigate · Enter open · Esc close