Loading Techie Utils…

Set-Cookie Header Builder

Write a Set-Cookie header with the right attributes for your framework. Free, and runs entirely in your browser — nothing you enter is uploaded or stored.

About Cookie Parser and Builder

A cookie is a name, a value and a set of attributes that tell the browser when to send it back. Browsers enforce rules on those attributes, and when a cookie breaks one it is not set. No error is shown to the page. This tool reads a cookie, applies those rules, and explains any it breaks.

The rejections are the ones people lose hours to. SameSite=None without Secure. A __Host- cookie with a Domain or without Path=/. Partitioned without Secure. An Expires date browsers cannot read. Each is reported as a problem. The softer risks are reported too: a session cookie scripts can read, a Domain that shares the cookie with every subdomain, and a lifetime past the 400-day cap browsers now apply.

Paste Set-Cookie headers to read what a server sends, or a Cookie header to read what a browser sends back. You can also build a cookie from its settings and get it as the header or as the call for Express, Next.js, Flask, Django, Go, PHP or browser JavaScript.

Where it helps

  • Applies the rules browsers enforce without telling you: prefixes, SameSite=None, Partitioned and unreadable dates.
  • Explains the lifetime precisely: Max-Age wins over Expires, an expiry in the past deletes the cookie, and browsers cap lifetimes at 400 days.
  • Flags session and auth cookies that scripts can read or that are sent over plain HTTP.
  • Writes the same cookie for eight targets and notes where they differ, such as Express using milliseconds and HttpOnly cookies being unreachable from document.cookie.
  • Runs in the browser and hides cookie values until you reveal them, since they are often live session credentials.

Limits

  • It checks each cookie on its own. Whether a browser sends it on a given request also depends on the request's site, path and scheme, which a pasted header does not include.
  • Browsers differ on some edge cases, such as the default when SameSite is not set, and on third-party cookies generally. The checks follow current Chromium and the RFC 6265bis draft.

Frequently asked questions

Why isn't my cookie being set?

The common causes are SameSite=None without Secure, a __Host- or __Secure- prefix whose rules are not met, Secure on a page served over plain HTTP, a Domain that does not match the site, or the response being cross-origin without credentials: include on the fetch. Paste the Set-Cookie header here to check the first three.

Which SameSite value should I use?

Lax for most cookies: the cookie is sent when someone follows a link to your site, but not on cross-site form posts or in iframes. Strict for cookies that authorise sensitive actions, if you accept that users arriving from a link will appear logged out on the first page. None only for cookies that must work inside another site, such as an embedded widget, and always with Secure.

What does the __Host- prefix do?

It makes the browser guarantee three things before accepting the cookie: it was set over HTTPS with Secure, it has no Domain, so it belongs to this exact host, and its Path is /. A subdomain or a plain-HTTP page cannot then overwrite it, which is why it is recommended for session cookies.

What is a Partitioned cookie?

Partitioned opts a third-party cookie into CHIPS: the browser stores a separate copy for each top-level site the cookie is used on. An embedded chat widget can then keep its state on each site without that state being used to track the user across sites. It requires Secure.

Related tools

  • JWT — Read, verify and sign JSON Web Tokens
  • CSP Generator — Build a Content-Security-Policy, or check one, and write it for your server or framework
  • CORS Generator — Write CORS configuration for nginx, Express, Go, Django, ASP.NET, Spring and more, and test an origin against it
  • HTTP Headers — Grade a site's security headers from A+ to F, see every response header, and get the fix for your server
  • HTML Formatter — Indent and tidy HTML markup
  • CSS Formatter — Format stylesheets with consistent indentation

More Web Development tools