Skip to main content
Zimt

Home baking recipes and cinnamon favourites

Where Did Cookie Fix Start? Chrome’s SameSite Origin

The cookie fix began with Google Chrome’s rollout of the SameSite cookie attribute in 2016, which later became mandatory in early 2020 and prompted other browsers to adopt the same changes.

Background: why cookies needed fixing

When cookies were first introduced in the mid‑1990s, they were designed as a simple way for servers to remember small pieces of state, such as a shopping‑cart identifier. Over the years, developers began to rely on cookies for authentication tokens, user preferences, and even cross‑site tracking. This flexibility created a security blind spot: malicious sites could trigger a user’s browser to send cookies to a target domain without the user’s explicit consent, enabling cross‑site request forgery (CSRF) attacks.

By the 2010s, high‑profile data‑leak incidents and privacy concerns highlighted the need for a more robust default handling of cookies. The industry consensus was that browsers should enforce stricter rules unless a developer explicitly opted out. This led to the conception of the SameSite attribute, which tells a browser whether a cookie should be sent with cross‑origin requests.

How the SameSite attribute works

SameSite accepts three values: Strict, Lax, and None. A Strict cookie is only sent when the request originates from the same site that set the cookie, effectively blocking it on any cross‑site navigation. Lax permits the cookie on top‑level navigation GET requests (e.g., clicking a link) but blocks it on POST requests and sub‑resource loads. None restores the legacy behavior of sending the cookie on all requests, but it now requires the cookie to be marked Secure and transmitted over HTTPS.

The critical change introduced in the 2020 enforcement was that browsers would treat cookies lacking an explicit SameSite attribute as Lax by default. This shift meant that legacy code that relied on cookies being sent with cross‑site POSTs suddenly stopped working, prompting a wave of updates across the web ecosystem.

Implementation steps for developers

  1. Audit existing cookies: locate every Set-Cookie header in your application and note whether SameSite is specified.
  2. Determine the intended behavior: if a cookie is used for authentication, set SameSite=Strict or Lax depending on whether you need cross‑site POSTs.
  3. Update the header syntax: for example, Set-Cookie: sessionId=abc123; SameSite=Lax; Secure; HttpOnly.
  4. Test across browsers: verify that Chrome, Edge, Firefox, and Safari all respect the new attribute and that functionality (e.g., login flows) remains intact.
  5. Deploy gradually: use feature‑flags or a phased rollout to catch edge cases before a full production push.

When adding SameSite=None, remember that the Secure flag is mandatory. Attempting to set None without Secure results in the cookie being rejected by most modern browsers, which can appear as a silent login failure.

Common problems after the fix

Developers often encounter three recurring issues after the SameSite enforcement. First, third‑party analytics scripts that rely on cross‑site cookies stop receiving the expected data, leading to under‑reported traffic. Second, OAuth flows that involve redirects between domains may break if the state‑parameter cookie is not correctly marked. Third, legacy mobile web views sometimes ignore the Secure requirement, causing cookies to be dropped without clear error messages.

To troubleshoot, start by inspecting the Set-Cookie headers in the network tab of your browser’s developer tools. Look for missing SameSite or Secure attributes. If a request is being blocked, the console will usually log a message such as “Cookie ‘sessionId’ was rejected because it has the SameSite attribute set to ‘None’ without the Secure flag.” Adjust the header accordingly and re‑test.

Browser adoption and comparison

Chrome was the first major browser to implement the SameSite attribute in 2016 as an experimental feature, and it made the enforcement mandatory in version 80 (released in February 2020). Microsoft Edge, built on Chromium, inherited the same behavior at the same time. Firefox introduced support in version 69 (2019) and switched to the stricter default in version 91 (2021). Safari lagged slightly, adding full SameSite support in macOS Big Sur (2020) and iOS 14.5.

While the core semantics are identical, each browser has subtle differences in how they treat ambiguous cases. For example, Chrome treats an empty SameSite value as Lax, whereas older versions of Safari treated it as “unspecified” and fell back to legacy behavior. Firefox historically logged a warning in the console for missing attributes, which can help developers identify problems early.

Impact on security and privacy

The primary security benefit of the cookie fix is a dramatic reduction in CSRF attack surface. By defaulting to Lax, browsers prevent malicious sites from silently performing state‑changing POST requests on behalf of an authenticated user. This aligns with the principle of least privilege: cookies are only sent when truly needed.

From a privacy perspective, the SameSite attribute curtails the ability of third‑party trackers to piggyback on first‑party sites. When a site embeds content from a different domain, the embedded domain can no longer rely on automatically receiving the user’s cookies unless it explicitly opts in with SameSite=None; Secure. This has encouraged many advertisers to move toward server‑side tracking or to use privacy‑preserving alternatives such as the Storage Access API.

Alternatives to cookies for state management

Although cookies remain the most widely supported mechanism for server‑side session identifiers, several alternatives have gained traction, especially in single‑page applications (SPAs). Local storage and session storage provide larger payloads (up to 5 MB) but lack the automatic HTTP header inclusion that cookies enjoy, meaning developers must manually attach tokens to requests.

Another emerging pattern is the use of Authorization: Bearer tokens in the HTTP header, often backed by JSON Web Tokens (JWT). This approach separates authentication data from cookie handling entirely and can be combined with the SameSite attribute for any fallback cookies. However, developers must implement proper token revocation and rotation strategies to avoid long‑lived credentials.

Frequently Asked Questions

What does “SameSite=None; Secure” mean?

It tells the browser to send the cookie on all cross‑origin requests, but only over HTTPS. The Secure flag is required to protect the cookie from being intercepted on insecure connections.

Do older browsers ignore SameSite?

Browsers released before 2016 do not recognize the attribute and treat the cookie as legacy, sending it on every request. This is why many sites still include a fallback for these browsers.

Can I set SameSite on HttpOnly cookies?

Yes. SameSite, HttpOnly, Secure, and other flags are independent and can be combined in a single Set-Cookie header.

Will the SameSite change affect mobile apps that use WebViews?

Most modern WebViews follow the same rules as their underlying browser engine, but older Android System WebViews may still allow cross‑site cookies without SameSite enforcement. Testing on target devices is essential.

Is there a way to disable the SameSite enforcement for testing?

Chrome provides a flag (chrome://flags/#same-site-by-default-cookies) that can be toggled for local testing, but it should never be used in production environments.

Read next