Skip to content

SameSite and security

Pick the attributes, set the cookie, and check what the browser stored. Choosing sameSite: 'None' or partitioned with secure unchecked shows how CookieService turns Secure on for you (a warning appears in the browser console).

Live demo
Option What it does
sameSite: 'Lax' Default. Sent on same-site requests and on top-level navigations from other sites.
sameSite: 'Strict' Only sent on same-site requests. Following a link from another site arrives without it.
sameSite: 'None' Also sent on cross-site requests, such as iframes and fetch from another site. Requires Secure.
secure: true Only sent over HTTPS (browsers also allow it on http://localhost).
partitioned: true Stores the cookie separately for each top-level site (CHIPS). Requires Secure.
  • The stored attributes are read with the browser’s Cookie Store API, because document.cookie only exposes names and values. That inspector is part of this site, not of the library.
  • To delete a partitioned cookie, pass partitioned: true to delete() as well.
  • HttpOnly cookies can only be set by a server. See Server-side rendering.