To assess a website's session or login cookies, open DevTools (F12 → Application → Cookies in Chrome, or Storage → Cookies in Firefox) and check Secure, HttpOnly, and SameSite against each cookie's purpose. Authentication secrets should generally use Secure and HttpOnly; Strict or Lax suits most first-party sessions, while legitimate cross-site flows may require SameSite=None with Secure and separate CSRF defenses. Secure limits transmission to HTTPS; HttpOnly blocks JavaScript from reading the cookie, although an XSS bug can still act on the user's behalf; SameSite restricts cross-site sending, though explicit Lax permits top-level cross-site navigations using safe HTTP methods, including GET and HEAD. Some browsers' default-Lax behavior may also send recently set cookies on cross-site POST requests. A recognizable username or email in a cookie value is not, by itself, proof of a vulnerability. Passwords, API keys, or other secrets in a readable value are a serious concern; inspect an unfamiliar token's purpose before judging it.
That's the checklist an AI Overview will hand you. What it can't show you is the why behind each flag, the exact Set-Cookie strings that pass and fail, the decision tree for which SameSite value a given cookie should use, or how to read the browser prefixes (__Secure-, __Host-) that quietly enforce all of this at the browser level. The diagram and tables below map the whole cookie surface so you can audit a site in under a minute — and fix your own.
The following diagram wraps one illustrative Set-Cookie header across two visual lines. An actual HTTP header must keep the cookie and its attributes on one line.
For security professionals auditing websites, developers reviewing implementations, or privacy-conscious users evaluating sites they interact with, understanding how to assess cookie security is essential. This guide provides a systematic approach to evaluating cookie configurations, identifying security issues, and understanding what separates secure cookies from dangerous ones.
Key Indicators of Secure Cookies
Several attributes and configurations signal that cookies are properly secured against common attacks.
1. The Secure Flag is Present
What to Look For: Secure on authentication and other sensitive cookies for HTTPS websites, ensuring those cookies only transmit over encrypted connections.
Why It Matters: Without Secure, cookies sent over HTTP can be intercepted by attackers on the same network, enabling session hijacking through man-in-the-middle attacks. On public WiFi, unencrypted cookie transmission exposes users to trivial credential theft.
How to Check:
Set-Cookie: session_id=abc123; Secure; HttpOnly; SameSite=Lax
The Secure attribute should appear on authentication and other sensitive cookies served over HTTPS. It is also a useful default for other cookies on HTTPS sites.
Red Flag: An authentication or sensitive cookie on an HTTPS website lacking Secure. It may be sent over HTTP when an eligible request occurs; assess other cookies according to what their values expose.
2. HttpOnly Flag on Session and Authentication Cookies
What to Look For: HttpOnly attribute on cookies used for authentication, session management, or storing sensitive identifiers.
Why It Matters: HttpOnly prevents JavaScript from reading cookies via document.cookie, reducing cookie theft through XSS. It does not prevent injected scripts from making authenticated requests.
How to Check:
Set-Cookie: session_id=abc123; Secure; HttpOnly; SameSite=Lax
Session cookies, authentication tokens, remember-me tokens, and any cookie containing sensitive identifiers should be HttpOnly.
Red Flag: An authentication secret accessible to JavaScript. If the site has an XSS flaw, injected code may be able to steal that value.
Acceptable Exception: Non-sensitive cookies like theme preferences, language selection, or UI state don't need HttpOnly because client-side JavaScript legitimately needs access to implement functionality.
3. SameSite Attribute is Configured
What to Look For: SameSite attribute set to Strict, Lax, or explicitly None (with Secure) based on cookie purpose.
Why It Matters: SameSite controls when cookies are sent with cross-site requests and helps reduce CSRF risk. Lax still sends cookies on top-level cross-site navigations using safe methods such as GET; use other CSRF defenses for sensitive actions.
Recommended Settings:
- Session cookies: SameSite=Lax or SameSite=Strict for typical first-party flows; None with Secure when cross-site use is required and CSRF is addressed separately
- CSRF tokens: SameSite=Strict
- Third-party integrations: SameSite=None; Secure (only when necessary)
How to Check:
Set-Cookie: session_id=abc123; Secure; HttpOnly; SameSite=Lax
Red Flag:
- Session cookies with SameSite=None when no cross-site flow requires it, or when sensitive actions lack other CSRF defenses
- Any cookie with SameSite=None but missing Secure flag (browsers will reject)
- Missing SameSite on sensitive cookies without a reviewed cross-site policy; browser defaults can vary
Which SameSite value should a given cookie use? The choice is almost mechanical once you know what the cookie is for:
Quick-Reference: What Each Attribute Does and When to Use It
| Attribute | What it does | Use on | Skip / avoid when |
|---|---|---|---|
| Secure | Cookie sent only over HTTPS | Authentication and sensitive cookies; a useful default for other HTTPS cookies | Review lower-risk cookies by purpose |
| HttpOnly | Blocks JavaScript (document.cookie) access | Session, auth, remember-me, CSRF-session cookies; CSRF token cookies when JavaScript need not read them | Preference/UI cookies JS must read; CSRF token cookies in cookie-to-header AJAX designs |
| SameSite=Strict | Withheld on cross-site requests | CSRF tokens, banking/high-value sessions | Login-via-external-link UX matters (use Lax) |
| SameSite=Lax | Explicit Lax permits top-level cross-site navigations using safe methods, including GET and HEAD; some browsers' default-Lax treatment also permits recent cookies on cross-site POST | General session cookies; set explicitly when relying on Lax behavior | Cross-site sending beyond those navigations is needed (consider None) |
| SameSite=None | Allows cross-site sending, subject to other browser restrictions | Sessions, SSO, or embeds that need cross-site use — with Secure and separate CSRF defenses | Cookies that do not need cross-site use |
__Host- prefix | Browser enforces Secure + Path=/ + no Domain | The most sensitive session cookie | You need a Domain attribute or subdomain scope |
__Secure- prefix | Browser enforces Secure flag | Sensitive cookies needing a Domain scope | Non-sensitive cookies |
| Appropriate Max-Age | Limits browser storage time; server-side expiry or revocation bounds replay of a copied cookie | Session/auth cookies, alongside server-side timeouts, based on risk and user experience | Non-sensitive preference cookies can have longer lifetimes |
4. Appropriate Expiration Times
What to Look For: An expiration policy suited to the cookie's purpose and the account's risk, with shorter lifetimes for more sensitive sessions.
Why It Matters: Long-lived authenticated sessions extend the window of opportunity for stolen credentials. Set server-side idle and absolute timeouts; a browser-session cookie alone does not enforce them.
Best Practices:
- Session cookies: Choose idle and absolute server-side timeouts based on risk; align the cookie lifetime with that policy.
- Remember-me tokens: Use a separate, revocable token with a lifetime suited to the use case.
- Preference cookies: Longer lifetimes can be reasonable when the values are non-sensitive.
How to Check:
Set-Cookie: session_id=abc123; Secure; HttpOnly; SameSite=Lax; Max-Age=3600
Red Flag:
- Sessions without a server-side idle timeout or absolute expiry
- Long-lived authentication cookies without a documented need or revocation mechanism
- Extremely long expiration on sensitive data
5. No Sensitive Data in Cookie Values
What to Look For: Cookie values contain only session identifiers or encrypted tokens, not actual sensitive data in plain text.
Why It Matters: Browsers store cookies on user devices and send eligible cookies with matching requests. Storing passwords, credit card numbers, social security numbers, or other sensitive data directly in cookies is a critical security flaw.
Secure Pattern:
Set-Cookie: session_id=a1b2c3d4e5f6; Secure; HttpOnly
// Server-side session stores actual user data
Insecure Pattern:
Set-Cookie: user_data=username:john|password:abc123|ssn:123-45-6789
// Sensitive data in plain text - NEVER DO THIS
How to Check: Inspect cookie values (using browser DevTools) and look for recognizable sensitive information like:
- Passwords or password hashes
- Credit card numbers
- Social security numbers
- API keys or secrets
- Full names and addresses in plain text
Red Flag: Passwords, payment details, secrets, or other sensitive information exposed in readable cookie values. A username or email alone is not proof of a vulnerability; evaluate its purpose and privacy impact. If sensitive data is stored in a protected token, review how it is encrypted, authenticated, and expired.
6. Proper Cookie Prefixes
What to Look For: Use of __Secure- or __Host- cookie prefixes for sensitive cookies, enforcing additional security requirements.
Why It Matters: Cookie prefixes provide an extra layer of protection by enforcing security attributes at the browser level, preventing misconfiguration.
__Secure- Prefix:
Set-Cookie: __Secure-session_id=abc123; Secure; HttpOnly; SameSite=Lax
Enforces that cookie must have Secure attribute. Browsers reject __Secure- cookies without Secure flag.
__Host- Prefix:
Set-Cookie: __Host-session_id=abc123; Secure; HttpOnly; SameSite=Lax; Path=/
Enforces:
- Must have Secure attribute
- Must not have Domain attribute (sent only to exact host)
- Must have Path=/
Use Cases:
- Critical session cookies: __Host- prefix
- Security-sensitive cookies: __Secure- prefix
- Regular cookies: No prefix needed
Red Flag: High-security applications (banking, healthcare, government) not using cookie prefixes on authentication cookies.
Tools and Methods for Cookie Analysis
Several approaches enable systematic cookie security assessment.
Method 1: Browser Developer Tools
All modern browsers include built-in cookie inspection tools.
Chrome/Edge DevTools:
- Open DevTools (F12 or Ctrl+Shift+I / Cmd+Option+I)
- Navigate to Application tab
- Expand "Cookies" in left sidebar
- Select domain to inspect
- Review table showing all cookie attributes
What to Look For:
- Name column: Cookie identifiers
- Value column: Cookie contents (check for sensitive data)
- Domain column: Which domains can access cookie
- Path column: Which paths cookie applies to
- Expires/Max-Age column: When cookie expires
- HttpOnly column: Checkmark indicates HttpOnly is set
- Secure column: Checkmark indicates Secure is set
- SameSite column: Shows Strict, Lax, or None
- Partition Key column: Indicates cookie partitioning status
Firefox Developer Tools:
- Open DevTools (F12)
- Go to Storage tab
- Expand Cookies
- Select domain
- Review cookie properties
Similar layout showing all cookie attributes for inspection.
Method 2: Cookie Analyzer Tools
Specialized tools provide automated cookie security analysis.
Online Cookie Analyzers:
- Analyze cookies supplied to the tool or accessible in its page context; ordinary page JavaScript cannot read HttpOnly cookies or cookies scoped to other origins
- Flag security issues automatically
- Provide recommendations
- Compare against security best practices
Cookie Analyzer
Analyze HTTP cookies for security issues and privacy concerns
Open the full Cookie Analyzer tool →Features to Look For:
- Automatic detection of missing Secure flags
- Identification of authentication cookies without HttpOnly
- SameSite misconfiguration alerts
- Sensitive data detection in cookie values
- Cookie prefix recommendations
- Expiration analysis
Method 3: Security Scanners
Web application security scanners include cookie analysis as part of comprehensive assessments.
OWASP ZAP (Zed Attack Proxy):
- Free, open-source security scanner
- Automated cookie security checks
- Reports missing security attributes
- Identifies insecure cookie patterns
Burp Suite:
- Professional security testing tool
- Comprehensive cookie analysis
- Custom cookie rules and checks
- Integration with manual testing workflows
Acunetix, Netsparker, Qualys:
- Commercial scanners with cookie security modules
- Automated vulnerability detection
- Compliance checking (PCI-DSS, GDPR)
- Detailed remediation guidance
Method 4: Browser Extensions
Privacy and security-focused browser extensions continuously monitor cookies.
Cookie AutoDelete:
- Automatically deletes cookies when tabs close
- Whitelist/blacklist functionality
- Shows which cookies are set by each site
EditThisCookie:
- Cookie manager and editor
- Inspect and modify cookies
- Export/import cookie data
- Security attribute display
Privacy Badger / uBlock Origin:
- Block tracking cookies
- Identify third-party cookies
- Show which domains set cookies on each page
Red Flags: Signs of Insecure Cookies
Certain patterns indicate poor cookie security that should raise immediate concerns.
Critical Red Flags
1. Session Cookies Without HttpOnly: Allows an XSS flaw to read the cookie through JavaScript; HttpOnly reduces this theft path but does not prevent XSS.
Severity: Critical Attack Vector: XSS-based session theft Recommendation: Add HttpOnly to all session cookies immediately
2. Authentication or Sensitive Cookies Without Secure on HTTPS Sites: These cookies may transmit over HTTP on eligible requests, exposing their values on unsecured networks.
Severity: High when the cookie carries a sensitive value Attack Vector: Man-in-the-middle attacks, especially on public WiFi Recommendation: Add Secure to authentication and sensitive cookies; consider it the default for other HTTPS cookies
3. Sensitive Data Stored in Cookie Values: Passwords, credit cards, SSNs, or other sensitive data visible in cookies is critical vulnerability.
Severity: Critical Attack Vector: Direct data exposure, regulatory violation Recommendation: Never store sensitive data in cookies; use session IDs referencing server-side data
4. Authentication Cookies with Unjustified Long Expiration: Long-lived authentication cookies can extend the window for stolen cookie exploitation when they lack server-side expiry or revocation.
Severity: Medium to High Attack Vector: Extended session hijacking window Recommendation: Set idle and absolute server-side timeouts according to risk, and support revocation
5. SameSite=None on Session Cookies Without a Cross-Site Need: This setting permits cross-site sending where browser policy allows it; without other CSRF defenses, sensitive actions may be exposed.
Severity: Depends on the cross-site flow and CSRF defenses Attack Vector: CSRF attacks Recommendation: Use Lax or Strict when cross-site sending is unnecessary; otherwise keep None with Secure and add appropriate CSRF defenses
Warning Signs
1. Many Third-Party Cookies: Large numbers of tracking cookies from advertising and analytics platforms indicate potential privacy issues, though not necessarily security vulnerabilities.
2. No Cookie Prefixes: The absence of __Secure- or __Host- prefixes does not by itself show a security problem. Review the cookie's attributes and scope.
3. Inconsistent Cookie Security: Some cookies secured properly while others aren't indicates inconsistent security practices and potential oversight.
4. Legacy Cookie Names: Conventional names such as PHPSESSID, JSESSIONID, and ASP.NET_SessionId do not show whether a cookie is secure. Check its attributes, value, scope, and server-side session policy instead.
Security Best Practices: The Ideal Configuration
A well-secured website follows these cookie security patterns:
The following Set-Cookie examples are split across lines for readability. Each cookie and its attributes must be sent as a single header line; the displayed line breaks are not literal HTTP header syntax.
For Session/Authentication Cookies
Ideal Configuration:
Set-Cookie: __Host-session=abc123xyz;
Secure;
HttpOnly;
SameSite=Strict;
Path=/;
Max-Age=3600
Characteristics:
- __Host- prefix enforcing strict security
- Secure flag (HTTPS-only transmission)
- HttpOnly flag (JavaScript can't access)
- SameSite=Strict (maximum CSRF protection)
- Path=/ (applies to entire site)
- Max-Age=3600 (an example one-hour cookie lifetime; enforce server-side expiry separately)
For CSRF Tokens
Ideal Configuration:
Set-Cookie: __Secure-csrf_token=xyz789;
Secure;
SameSite=Strict;
Path=/;
Max-Age=3600
Characteristics:
- __Secure- prefix
- Secure flag
- HttpOnly is omitted here for a cookie-to-header AJAX design in which JavaScript reads the token; a server-rendered form can use a different design
- SameSite=Strict
- Short expiration matching session lifetime
For User Preferences
Ideal Configuration:
Set-Cookie: preferences=theme:dark|lang:en;
Secure;
SameSite=Lax;
Path=/;
Max-Age=31536000
Characteristics:
- Secure flag
- NOT HttpOnly (client-side JavaScript needs access)
- SameSite=Lax (no cross-site restrictions needed)
- Long expiration (1 year) acceptable for preferences
For Third-Party Integrations
Ideal Configuration:
Set-Cookie: integration_token=token123;
Secure;
SameSite=None;
Path=/;
Max-Age=7200
Characteristics:
- Secure flag (required with SameSite=None)
- SameSite=None (allows cross-site access when necessary)
- Example 2-hour cookie lifetime; choose a duration based on risk and enforce server-side expiry
- Only used when cross-site access is truly necessary
Testing Your Own Website
For developers and site owners, systematic testing ensures cookie security.
Testing Checklist
1. Enumerate All Cookies: List every cookie your site sets across all pages and user actions (login, checkout, preferences, etc.).
2. Review Each Cookie: For each cookie, verify:
- Secure flag present on authentication and sensitive cookies; assess other HTTPS cookies by purpose
- HttpOnly set (if cookie contains sensitive data)
- Appropriate SameSite value (Strict/Lax for typical first-party flows, None with Secure when cross-site use is needed)
- Reasonable expiration time
- No sensitive data in cookie value
- Appropriate Domain and Path settings
3. Test Different Scenarios:
- Anonymous user browsing
- Logged-in user interaction
- Session timeout behavior
- Cross-origin requests (if applicable)
- Third-party integrations
4. Use Automated Tools: Run security scanners (OWASP ZAP, Burp Suite) to catch issues you might miss manually.
5. Review Framework Defaults: Check that your web framework's default cookie settings are secure. Many frameworks require explicit configuration for optimal security.
Common Framework Configurations
Express.js (Node.js):
app.use(session({
secret: process.env.SESSION_SECRET,
name: '__Host-session',
cookie: {
secure: true, // Requires HTTPS
httpOnly: true, // Prevents JS access
sameSite: 'strict', // CSRF protection
path: '/', // Required by __Host- prefix
maxAge: 3600000 // 1 hour
}
}));
Django (Python):
# settings.py
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Strict'
SESSION_COOKIE_AGE = 3600
SESSION_COOKIE_NAME = '__Host-sessionid'
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = 'Strict'
ASP.NET Core (C#):
services.AddSession(options =>
{
options.Cookie.Name = "__Host-session";
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
options.Cookie.HttpOnly = true;
options.Cookie.SameSite = SameSiteMode.Strict;
options.IdleTimeout = TimeSpan.FromMinutes(60);
});
Conclusion
Determining whether a website's cookies are secure requires examining multiple security attributes and configuration patterns. Authentication cookies should use Secure on HTTPS sites, use HttpOnly when JavaScript does not need the secret, configure SameSite for the required flow, maintain appropriate expiration times, and avoid exposing sensitive data in cookie values.
Red flags like authentication secrets readable by JavaScript, sensitive cookies missing Secure, or SameSite=None without a cross-site need or other CSRF defenses warrant investigation. Security-conscious websites configure Secure, HttpOnly, and SameSite according to cookie purpose, often with additional hardening through cookie prefixes.
For users evaluating websites, browser developer tools provide immediate visibility into cookie security. For developers and security professionals, systematic testing with automated scanners combined with manual inspection supports a more complete cookie security assessment.
Want to analyze cookie security for websites you visit or manage? Use our Cookie Analyzer tool to review cookies you provide or that its page context can access, identify potential configuration issues, and get recommendations. Check HttpOnly and other-origin cookies separately with DevTools or a suitable scanner.
