Skip to content

Set-Cookie header analyzer

Paste Set-Cookie headers to check Secure, HttpOnly, SameSite, prefixes, domain, path and expiry, cookie by cookie.

Runs in your browser. Nothing you paste is sent to us.

Set-Cookie headers

Sample cookies are filled in: three shaped like Keycloak’s and one app cookie with mistakes. Paste your own.

This reads the text you paste. It does not contact any site.

KEYCLOAK_IDENTITY

No problems

Keycloak’s single sign-on session token. It should be Secure and HttpOnly.
Value
sample.identity.value
Expires
When the browser session ends
Path
/realms/acme/
Domain
(this host only)
Secure: sent over HTTPS only.
HttpOnly: scripts cannot read it, which limits what XSS can steal.
SameSite=None: sent on cross-site requests too, as embedded and cross-site sign-in needs. Browsers that block third-party cookies may still drop it in iframes.
Version is not a cookie attribute browsers use; they ignore it.

KEYCLOAK_SESSION

1 to improve

Keycloak’s session cookie. Keycloak leaves it readable by scripts on purpose, for its session status check.
Value
sample-session-id
Expires
36,000 seconds after it is set (Max-Age)
Path
/realms/acme/
Domain
(this host only)
Secure: sent over HTTPS only.
No HttpOnly: page scripts can read it. Fine only if your own scripts need it.
SameSite=None: sent on cross-site requests too, as embedded and cross-site sign-in needs. Browsers that block third-party cookies may still drop it in iframes.
Version is not a cookie attribute browsers use; they ignore it.

AUTH_SESSION_ID

No problems

The Keycloak login that is in progress, before the user has signed in.
Value
sample-auth-session
Expires
When the browser session ends
Path
/realms/acme/
Domain
(this host only)
Secure: sent over HTTPS only.
HttpOnly: scripts cannot read it, which limits what XSS can steal.
SameSite=None: sent on cross-site requests too, as embedded and cross-site sign-in needs. Browsers that block third-party cookies may still drop it in iframes.

app_session

2 to fix 1 to improve

Value
sample
Expires
When the browser session ends
Path
/
Domain
.example.com
No HttpOnly: page scripts can read it. Fine only if your own scripts need it.
Domain=.example.com: also sent to every subdomain of example.com. Leave Domain out to keep it to this host.

How to use it

  1. Copy the Set-Cookie headers from the browser’s network panel or curl -i.
  2. Paste them, one per line.
  3. Read each cookie’s findings, most serious first.
  4. Fix the attributes where the cookie is set and check again.

What to know

Secure keeps a cookie off plain HTTP, HttpOnly hides it from scripts, and SameSite decides whether it goes along on requests from other sites. Session cookies should have all three.

SameSite=None is needed for cookies used across sites, for example in iframes, and browsers reject it without Secure. Browsers that block third-party cookies may drop such cookies anyway.

Keycloak sets cookies such as KEYCLOAK_IDENTITY, KEYCLOAK_SESSION and AUTH_SESSION_ID on the realm’s path. This tool recognizes them and says what each is for.

Secure, HttpOnly and SameSite in practice

These three attributes do most of the protective work.

Secure

Without Secure, a cookie is also sent over plain HTTP, where anyone on the network path can read it. Every cookie on an HTTPS site should be Secure. Browsers also refuse to let an insecure page overwrite a Secure cookie.

HttpOnly

HttpOnly keeps a cookie out of reach of page scripts. If an attacker injects a script, they cannot read an HttpOnly session cookie and send it away. It does not stop the script from making requests that carry the cookie, so it limits damage rather than preventing it. Session cookies should be HttpOnly unless your own JavaScript must read them.

SameSite

ValueSent on cross-site requests?Typical use
StrictNever, not even when following a link from another siteHigh-value actions where a fresh sign-in is acceptable
LaxOnly on top-level navigations with safe methods, such as following a linkMost session cookies
NoneAlways; requires SecureCookies that must work in cross-site frames or requests

Chrome and Edge treat a cookie without SameSite as Lax. Other browsers have their own defaults, so set it explicitly. SameSite=None without Secure is rejected outright.

Expiry, Max-Age and lifetime limits

A cookie with neither Max-Age nor Expires is a session cookie: it ends when the browser session ends, though browsers that restore sessions may keep it longer. Max-Age gives a lifetime in seconds and takes precedence over Expires when both are present. A Max-Age of zero or less, or an Expires date in the past, deletes the cookie.

Browsers also cap lifetimes. Current versions of Chrome limit cookie lifetimes to 400 days whatever the server asks. Size is limited too: a name and value over 4,096 bytes are dropped.

What this analyzer does and does not do

  • It reads one or more Set-Cookie lines, with or without the header name.
  • For each cookie it checks Secure, HttpOnly, SameSite, prefixes, Domain, Path, lifetime, size and unknown attributes, and rates the findings.
  • It recognizes Keycloak’s cookies and says what each is for.
  • It reads text only. It does not visit your site or read your browser’s cookies.
  • It cannot see the context a cookie is set in, such as whether the page is HTTPS or which host set it. Keep that in mind when reading findings about Domain and Secure.

How to check your cookies

  1. Sign in to your app with the browser’s developer tools open on the Network tab.
  2. Find the response that sets the session cookie, often the redirect after login, and copy its Set-Cookie headers.
  3. Paste them here, one per line.
  4. Fix red findings first, then amber ones.
  5. Repeat for the identity provider’s own cookies, which are set on its domain.
Fetching Set-Cookie headers from the command line (replace the URL)
curl -s -D - -o /dev/null https://app.example.com/ | grep -i '^set-cookie'

Keycloak’s cookies

Keycloak sets its own cookies on its domain, scoped to the realm’s path, /realms/<realm>/. The sample on this page shows cookies shaped like them, with placeholder values.

CookiePurpose
KEYCLOAK_IDENTITYThe single sign-on session token. HttpOnly.
KEYCLOAK_SESSIONIdentifies the session. Readable by scripts on purpose, for the session status check that client libraries use.
AUTH_SESSION_IDThe login in progress, before the user has finished signing in.
KC_RESTARTLets Keycloak restart a login whose authentication session expired.

Keycloak marks its cookies SameSite=None; Secure so that single sign-on works across sites, for example when an application on another domain checks the session in a hidden frame. SameSite=None requires Secure, which is one more reason Keycloak must be served over HTTPS in production.

Third-party cookie blocking

Browsers increasingly block cookies in cross-site frames. Features that rely on reading Keycloak’s cookies inside a frame on another site, such as the session status iframe and silent check-sso, can stop working when Keycloak and the app are on different sites. Serving both under one registrable domain, such as auth.example.com and app.example.com, avoids the problem, and recent versions of Keycloak’s JavaScript adapter detect blocked third-party cookies and stop relying on the frame.

Common mistakes

  • A session cookie without Secure or HttpOnly.
  • SameSite=None without Secure, which browsers reject, so the cookie never arrives.
  • A broad Domain such as .example.com, so every subdomain, including ones run by others, receives the session cookie.
  • A __Host- cookie with a Domain or a path other than /, which browsers drop.
  • Very long lifetimes for session cookies. Prefer short sessions with a refresh mechanism.
  • Setting a cookie from a different host and expecting a different Path or Domain to delete it. To delete, match the original name, domain and path.

Best practices

  • Session cookies: __Host- prefix, Secure, HttpOnly, SameSite=Lax or Strict, Path=/.
  • Use SameSite=None only for cookies that genuinely need cross-site use, and always with Secure.
  • Leave out Domain unless subdomains must share the cookie.
  • Keep session lifetimes short and end sessions on the server at logout, not only by deleting the cookie.
  • Never store tokens in cookies readable by JavaScript.

Security notes

Cookie attributes reduce risk but do not replace server-side checks. A stolen session cookie still works until the session ends on the server, so logout must end the session there, and sensitive actions should ask for a fresh sign-in.

SameSite is a helpful defense against cross-site request forgery, not a complete one. Requests from other subdomains of the same site count as same-site, so state-changing endpoints still need CSRF protection.

Do not paste real session cookie values into tools or tickets. The analyzer only needs the attributes; replace the value with a placeholder.

Questions

Frequently asked questions

What does SameSite=Lax mean?

The cookie is sent on same-site requests and when the user follows a link to your site, but not on most requests started by other sites, such as cross-site form posts, images or frames. It is the default in Chrome and Edge when SameSite is missing.

Why is my cookie with SameSite=None not being set?

Browsers reject SameSite=None cookies that lack the Secure attribute. Add Secure and serve the page over HTTPS.

What is the difference between Max-Age and Expires?

Max-Age sets a lifetime in seconds from now; Expires sets a date. When both are present, Max-Age wins. With neither, the cookie lasts for the browser session.

Should session cookies be HttpOnly?

Yes, unless your own scripts must read them. HttpOnly stops injected scripts from reading the cookie, which limits what a cross-site scripting bug can steal.

What is a __Host- cookie?

A cookie whose name starts with __Host- must be Secure, have Path=/ and no Domain. Browsers enforce this, so the cookie is bound to the exact host and cannot be set by a subdomain.

How do I delete a cookie?

Send Set-Cookie with the same name, Domain and Path, and Max-Age=0 or an Expires date in the past. If the domain or path differ, the browser treats it as a different cookie.

Why is KEYCLOAK_SESSION not HttpOnly?

Keycloak’s client libraries check the session from the browser, so this cookie is readable by scripts on purpose. The sensitive session token is in KEYCLOAK_IDENTITY, which is HttpOnly.

Does this tool read my browser cookies?

No. It only analyzes the Set-Cookie text you paste, in your browser, and sends nothing anywhere.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.