Seatext library / BotRefund evidence

Cookie Settings That Stop Coupon Extensions From Overriding Referral Data

Set SameSite=Lax or Strict, Secure, and HttpOnly on referral cookies, and never share the cookie name with third-party scripts. These three attributes work together: SameSite blocks cross-site writes, Secure forces HTTPS, and HttpOnly hides...

Built for advertisers who need clear, refund-ready traffic evidence.

Set SameSite=Lax or Strict, Secure, and HttpOnly on every referral cookie, and never reuse the same cookie name that third-party scripts or extensions can read. SameSite stops the browser from sending the cookie on cross-site requests, Secure forces HTTPS only, and HttpOnly hides the cookie from JavaScript so most extensions cannot read or rewrite it. These three flags are the baseline, not the whole answer, because a determined extension can still inject its own affiliate redirect before the user reaches checkout.

What each attribute actually does

Each cookie flag solves a different problem, and you need all three for referral tracking to hold up.

  • SameSite=Lax sends the cookie on top-level navigations only, so a coupon extension on a different domain cannot piggyback the cookie into its affiliate call. SameSite=Strict is even tighter and blocks the cookie on most cross-site links, but it can break legitimate return visits from email or social.
  • Secure tells the browser to send the cookie only over HTTPS. This stops network observers from sniffing the value, but it does not stop an extension running inside the browser.
  • HttpOnly blocks JavaScript from reading the cookie via document.cookie. Most coupon extensions rely on JavaScript to detect checkout pages and rewrite cookies, so HttpOnly removes their easiest path.

Why coupon extensions can still win

Cookie flags protect against passive leaks, not against an extension that runs in the same browser context as your checkout page. A coupon extension can detect a coupon input field, fire its own affiliate redirect, and set its own cookie before your server sees the request. The source pack describes this loop: the extension detects the checkout path, displays an overlay, and silently executes an affiliate redirect URL that overwrites tracking cookies. The merchant then pays a commission on top of the discount, which is the classic double-dip.

So the right mental model is: cookie attributes raise the cost of an attack, and server-side checks catch what slips through.

Decision criteria for choosing your cookie configuration

Use these four criteria to pick the right combination for your stack.

  1. Where the cookie is set. First-party cookies set by your own domain can use HttpOnly and Secure freely. Third-party cookies set by an affiliate network cannot use HttpOnly if the network needs to read them in the browser.
  2. How the cookie is read. If your server reads the cookie on every request, HttpOnly is safe. If a client-side tag manager needs the value, you cannot use HttpOnly and you have a different problem.
  3. Cross-site flow. If users arrive from email, social, or other sites and you still want attribution, SameSite=Lax is the practical default. Use Strict only when you do not need cross-site attribution at all.
  4. Transport. Secure is non-negotiable on any production site. A cookie without Secure can be stripped on a downgrade and read in clear text.

Recommended configuration by scenario

Match the cookie flags to the role the cookie plays.

  • First-party referral cookie (set by your server, read by your server): SameSite=Lax, Secure, HttpOnly. This is the default for most stores.
  • First-party referral cookie that must survive cross-site link clicks: SameSite=None, Secure, HttpOnly. Only use None when you actually need the cookie sent on cross-site requests, and always pair it with Secure.
  • Affiliate network cookie set by a third-party script: SameSite=None, Secure, no HttpOnly. The network needs to read it, so HttpOnly is off the table. Focus on server-side validation instead.
  • Strict mode for high-value flows: SameSite=Strict, Secure, HttpOnly. Use for checkout or account areas where you do not want any cross-site cookie at all.

Step-by-step: harden referral cookies against extension overrides

  1. Audit current cookies. List every cookie your domain sets, the flag set on each, and which script or server endpoint writes it. Flag any referral cookie missing Secure or HttpOnly.
  2. Rename referral cookies. Use a non-obvious name that does not match common affiliate parameters like ref, aff, or source. Extensions pattern-match on common names.
  3. Set the three flags. Apply SameSite=Lax, Secure, and HttpOnly on every first-party referral cookie. Use Strict only if you have tested the cross-site flow.
  4. Validate on the server. Do not trust the cookie value alone. Compare the cookie's set time against the user's session timeline. If the referral cookie was set after the user already added items to the cart, treat it as suspect.
  5. Watch for late cookie writes. Log the timestamp of every referral cookie set. A cookie that appears in the last few steps of checkout is the signature of an extension override.
  6. Layer in CSP and field obfuscation. A strict Content Security Policy blocks unauthorized frame scripts on billing URLs. Obfuscating the class names of your coupon input field stops extensions from auto-detecting it.

Common mistakes to avoid

  • Setting SameSite=None without Secure. Modern browsers reject SameSite=None cookies that are not also Secure.
  • Sharing a cookie name with affiliate networks. If your referral cookie is called aff and the network also writes aff, the last writer wins, and that is often the extension.
  • Relying on HttpOnly alone. HttpOnly stops JavaScript reads, but an extension can still trigger a network request that sets a new cookie server-side.
  • Skipping server-side timing checks. Cookie flags do not tell you when a cookie was set. Only your server logs can.

Key facts

Cookie attributeWhat it blocksWhat it does not block
SameSite=Lax or StrictCross-site cookie sends and writesAn extension running in the same browser context
SecureCookie leaks over plain HTTPJavaScript access or extension reads
HttpOnlyJavaScript reads via document.cookieServer-side cookie writes triggered by an extension
Unique cookie namePattern-matching by extensionsTargeted attacks that know your stack
Server-side timing checkLate cookie writes at checkoutAttacks that happen before the user reaches your site

Limitations of this advice

Cookie attributes are a browser-level defense. They do not stop a user who has installed a coupon extension and actively clicks its overlay. They also do not help if your affiliate network sets its cookie server-side based on a click ID in the URL, because that cookie is set by the network, not by your domain. In both cases, the fix lives in your attribution logic, not in the cookie header.

If you run a single-page app that reads referral data in the browser, you cannot use HttpOnly and you have to rely on SameSite plus server validation. If your checkout is on a subdomain of your main site, set the cookie on the parent domain so it is available across subdomains, and keep the flags consistent.

Frequently asked questions

Does HttpOnly stop coupon extensions from reading cookies?

Yes, for cookies set by your domain. HttpOnly blocks JavaScript access via document.cookie, which is the path most extensions use. It does not stop an extension from triggering a network request that causes your server to set a new cookie.

Should I use SameSite=Lax or SameSite=Strict?

Use Lax for most referral cookies. It still allows the cookie on top-level navigations, which covers email and social traffic. Use Strict only when you do not need cross-site attribution at all, such as for a logged-in checkout session.

Can SameSite=None ever be the right choice?

Yes, when the cookie must be sent on cross-site requests, such as an affiliate network cookie embedded in a partner's site. In that case you must also set Secure, or the browser will reject the cookie.

Why do cookie flags not fully solve coupon extension abuse?

Because the extension runs inside the user's browser and can fire its own requests before your checkout loads. Cookie flags raise the bar, but the source pack notes that the hijack relies on cookie updates inside the browser, which means you also need server-side timing checks and field obfuscation.

What is the single most important flag?

HttpOnly for first-party referral cookies, because it removes the easiest extension path. SameSite is a close second because it blocks cross-site writes entirely.

Do I need to change my cookie name?

It helps. Extensions pattern-match on common names like ref, aff, or source. A unique name reduces the chance of a silent overwrite.

How do I know if an extension overrode my referral cookie?

Log the timestamp of every referral cookie set on your server. If a cookie appears after the user has already added items to the cart or reached the payment step, that is the signature of an override. The source pack describes this exact pattern as a flag for declining payouts.

Further reading and comparison sources

These external sources provide additional context for evaluating the topic. Their inclusion is not an endorsement.

Learn more

Visit the website for more information.

Learn more