What Does Your Site Store Before Anyone Clicks the Banner? A Pre-Consent Check on 7 Test Pages
The setup
Everything below ran on 25 November 2026 on a Linux machine:
- A small Python HTTPS server with a self-signed certificate that answers for three made-up hostnames:
shop.test(the site),tracker.test(a third-party analytics script) andvideo.test(a video embed). Chrome resolved all three to the local machine. - Chrome 156, headless, driven by Playwright. Every page got a new, empty browser profile.
- One shared test banner with Accept and Reject buttons. When it gets an answer, it stores a consent cookie for 180 days.
- The fake tracker does what many real ones do: when its script runs, it writes a first-party cookie (
_trk_id, requested for two years) and alocalStorageentry, then calls home, and its server answers with a third-party cookie (tuid, one year). - The fake video embed sets a cookie from its server, another from its script, and a volume setting in
localStorage.
The seven pages:
- Clean: the tracker loads only after Accept.
- Tag in the head: the tracker's
<script>sits in the<head>, as copied from a setup guide. - Server session cookie: the server sends
PHPSESSIDwith the page, the waysession_start()does in PHP. - Embed: a video
<iframe>in the page, loaded right away. - Reject ignored: clean before the answer, but the Reject handler also loads the tracker (a bug I've seen in hand-rolled banners).
- Stateless beacon: a first-party
sendBeaconto/collectwith no cookie and no storage. - Banner remembers early: the banner writes its own state cookie and
localStorageentry when it appears, before any answer.
A cookie banner is a question. The trouble is that a lot of sites act before the visitor answers it. A tag in the <head> has already written its ID, the server has already sent a session cookie, and an embedded video has already set its own cookies in a frame the banner doesn't control.
None of that shows up when you look at the banner. It shows up in the browser's storage, and you can check it in about ten minutes.
To see what such a check catches and what it misses, I built seven small test pages, each with one typical pattern. Then I loaded every page in a fresh Chrome profile, listed what was stored and sent before any answer, clicked Reject, and listed what was new.
This article walks through what I found, the manual DevTools routine, a short script that does the same, and how to read the results.
One thing up front: this is a technical check, not legal advice. What has to wait for consent depends on where your visitors are and what each cookie is for. The check tells you what happens. Whether it's allowed is a question for your regulator's guidance or a lawyer.
What each page stored
| Page | Before any answer | New after Reject |
|---|---|---|
| 1 Clean | nothing | consent cookie |
| 2 Tag in the head | _trk_id cookie (400 days), tuid third-party cookie (365 days), _trk_uid in localStorage, 2 requests to tracker.test |
consent cookie |
| 3 Server session cookie | PHPSESSID (session, HttpOnly) |
consent cookie |
| 4 Embed | vid_pref (180 days) and vid_session on video.test, player-volume in video.test's localStorage, 1 request |
consent cookie |
| 5 Reject ignored | nothing | consent cookie, plus _trk_id, tuid, _trk_uid and 2 requests to tracker.test |
| 6 Stateless beacon | nothing stored, 1 POST to shop.test/collect |
consent cookie |
| 7 Banner remembers early | consent_seen cookie (365 days), cmp_state in localStorage |
consent cookie |
This is the raw output for page 2, from the script further down:
== before any answer
cookie _trk_id on shop.test 400 days SameSite=Lax
cookie tuid on tracker.test 365 days Secure SameSite=None
storage _trk_uid on shop.test
request GET tracker.test/t.js
request GET tracker.test/b
== new after clicking "Reject"
cookie consent on shop.test 180 days SameSite=Lax
Four things stood out
1. The "before" snapshot alone would pass page 5
Page 5 looks perfect before the answer: nothing stored, nothing sent. The problem only appears when someone says no:
== before any answer
== new after clicking "Reject"
cookie consent on shop.test 180 days SameSite=Lax
cookie _trk_id on shop.test 400 days SameSite=Lax
cookie tuid on tracker.test 365 days Secure SameSite=None
storage _trk_uid on shop.test
request GET tracker.test/t.js
request GET tracker.test/b
So a pre-consent check has two halves. Look before the answer, then click Reject and look again. Accept is the least interesting button to test.
2. A private window missed two of the problems
The obvious way to get a "fresh visitor" is a private window. In Chrome, Incognito blocks third-party cookies by default. Most visitors don't browse that way.
To see what difference that makes, I ran pages 2 and 4 again with Chrome's BlockThirdPartyCookies policy switched on, which is the same restriction:
### 02-tag-in-head (BlockThirdPartyCookies policy)
== before any answer
cookie _trk_id on shop.test 400 days SameSite=Lax
storage _trk_uid on shop.test
request GET tracker.test/t.js
request GET tracker.test/b
### 04-embed (BlockThirdPartyCookies policy)
== before any answer
storage (storage blocked) on video.test
request GET video.test/embed
The tracker's own tuid cookie disappeared from page 2, and page 4 looked almost clean: no cookies at all, and the embed's storage blocked. For a visitor with default settings, the same embed set two cookies and a localStorage entry before they had answered anything.
The first-party _trk_id survived, because the tracker's script wrote it on your own domain. Blocking third-party cookies doesn't touch that.
So run the check in a fresh normal profile (a new Chrome profile, or a guest window), not only in Incognito.
3. The server can set a cookie before your JavaScript even runs
On page 3, PHPSESSID arrived with the HTML itself. The banner script hadn't loaded yet, so no banner logic can prevent it.
That's what calling session_start() at the top of every page does in PHP, and frameworks often do the same: Laravel's default web middleware sends a session cookie and an XSRF-TOKEN cookie with every response.
Whether that counts as necessary depends on what the session is for. A login or a shopping cart is a different case from a session started for every anonymous visitor who reads a blog post. If nothing uses the session, the simplest fix is not to start it until something does.
A detail in the output: the server sent PHPSESSID without any SameSite attribute, and the cookie list still says SameSite=Lax. That's Chrome applying its default to cookies that don't specify one. Your DevTools may show the attribute column empty for the same cookie.
4. Chrome trimmed the two-year cookie to 400 days
The tracker asked for Max-Age=63072000, which is 730 days. Chrome stored 400. Chrome caps cookie lifetimes at 400 days, so whatever a script asks for, that's the most you'll see in Chrome.
That cap doesn't make the cookie short-lived in regulatory terms. France's data protection authority (CNIL), for example, exempts some audience-measurement cookies from consent only under strict conditions, and recommends a lifetime of 13 months that isn't extended on each visit (CNIL: Cookies, solutions pour les outils de mesure d'audience). Thirteen months is about 396 days, so 400 days is already slightly over.
Also, the exemption covers the site's own audience measurement, not trackers that follow people across sites. A reader reminded us after an earlier post that rules like this differ by country, and it's a good reminder: check the guidance where your visitors are.
What the stateless page shows, and what it doesn't
Page 6 is the pattern privacy-friendly analytics tools use. It sends one request and stores nothing:
== before any answer
request POST shop.test/collect
== new after clicking "Reject"
cookie consent on shop.test 180 days SameSite=Lax
That's what a cookieless setup should look like in this check: a request in the Network panel and an empty Application panel.
Two caveats: "Nothing stored" isn't the same as "no personal data". The request still carries an IP address and a user agent, and data protection rules still apply to what the server does with them.
Page 7's banner wrote its own state before any answer. Some guidance treats remembering the visitor's actual choice as necessary, but a banner that stores a "seen" flag and a timestamp when it first appears is a different thing. The cleanest version stores nothing until the visitor answers, as page 1 does.
The 10-minute manual check
You don't need a script. In Chrome:
- Start fresh. Open a new guest window or a new Chrome profile (not only Incognito, see above). Open DevTools before you load the page.
- Set up the Network panel. Tick Preserve log. In the filter box, type
-domain:yoursite.comto hide your own requests and show everything else. - Load the page and don't touch the banner. Wait a few seconds.
- Read the Application panel. Under Storage, open Cookies and click every origin listed, including the ones that belong to embedded frames. Then Local storage, Session storage and IndexedDB. Write down each name, its domain and its expiry.
- Read the Network panel. Note every third-party request made before the answer.
- Click Reject. Repeat steps 4 and 5 and note what's new.
- Open a second fresh window and click Accept. Check that what loads is what your banner and policy describe.
- Repeat on a page with an embed (a video, map, chat widget or social post), and on a page that doesn't go through your usual template, such as a landing page or the checkout.
- If your banner only appears in some countries, run the check from those countries (a VPN works). Otherwise you'll be testing a page your visitors in those countries never see.
Reading a cookie's attributes
For each cookie, you want the lifetime and the flags. You can read them in DevTools (Application, then Cookies) or copy the Set-Cookie header from the Network panel.
A Max-Age of 63072000 seconds is two years (and Chrome will keep it for 400 days). Remember that a cookie with perfect security flags can still be one you shouldn't set before the answer.
A 48-line script that does the same
This is what produced every output above. It opens the page in a fresh profile, lists cookies, localStorage and sessionStorage in every frame, records third-party requests (plus your own fetch and beacon calls), clicks the Reject button and lists what's new.
# Pre-consent check: what does a page store and send before the visitor answers the banner, and after "Reject"?
# Usage: python3 check.py URL [reject-button-text] [extra Chrome flags] (pip install playwright)
import sys, time
from urllib.parse import urlsplit
from playwright.sync_api import sync_playwright
def snapshot(ctx, page):
cookies = {(c['name'], c['domain']): c for c in ctx.cookies()}
storage = {}
for f in page.frames:
try:
keys = f.evaluate('() => Object.keys(localStorage).concat(Object.keys(sessionStorage).map(k => "session:" + k))')
except Exception:
keys = ['(storage blocked)']
for k in keys:
if urlsplit(f.url).hostname:
storage[(urlsplit(f.url).hostname, k)] = 1
return cookies, storage
def report(label, cookies, storage, requests, seen=({}, {})):
print(f'== {label}')
for key, c in cookies.items():
if key in seen[0]:
continue
days = 'session' if c['expires'] < 0 else f"{(c['expires'] - time.time()) / 86400:.0f} days"
flags = ' '.join(x for x in ('HttpOnly' * c['httpOnly'], 'Secure' * c['secure'], 'SameSite=' + c['sameSite']) if x)
print(f"cookie {c['name']:<12} on {c['domain']:<14} {days:<9} {flags}")
for (host, k) in storage:
if (host, k) not in seen[1]:
print(f'storage {k:<12} on {host}')
for r in requests:
print(f'request {r}')
url, reject = sys.argv[1], (sys.argv[2] if len(sys.argv) > 2 else 'Reject')
site = urlsplit(url).hostname
with sync_playwright() as p:
# executable_path: your installed Chrome; remove it to use Playwright's own Chromium
browser = p.chromium.launch(executable_path='/usr/bin/google-chrome', headless=True, args=sys.argv[3:])
ctx = browser.new_context(ignore_https_errors=True) # fresh, empty profile for every run
page = ctx.new_page(); sent = []
def on_request(r):
host = urlsplit(r.url).hostname
if host and (host != site or r.resource_type in ('fetch', 'xhr', 'ping', 'beacon')):
sent.append(f'{r.method} {host}{urlsplit(r.url).path}')
page.on('request', on_request)
page.goto(url, wait_until='load'); page.wait_for_timeout(3000)
before = snapshot(ctx, page); report('before any answer', *before, sent)
sent.clear()
try:
page.get_by_role('button', name=reject).click(timeout=3000); page.wait_for_timeout(2000)
report(f'new after clicking "{reject}"', *snapshot(ctx, page), sent, seen=before)
except Exception as e:
print(f'== no "{reject}" button found ({type(e).__name__})')
browser.close()
Run it as python3 check.py https://yoursite.com/ "Reject all" with the exact text of your Reject button. If the button isn't found, the script says so instead of guessing.
Remove ignore_https_errors=True when you check a real site; I only needed it for the self-signed test certificate.
What it doesn't check
I want to be clear about the gaps, because a clean result from a limited check is easy to over-trust:
- It doesn't list IndexedDB, Cache Storage or service workers. Check those by hand in the Application panel.
- It doesn't detect fingerprinting, which stores nothing and reads device properties instead.
- It waits three seconds. Tags that fire on scroll, on a timer or on the second page view won't show up.
- Headless Chrome isn't a real visitor. Some consent tools and tag managers behave differently for automated browsers or by country.
- I tested only on my own test pages, from one location, in one browser.
- It doesn't tell you what's allowed. A session cookie for a cart and an advertising ID both show up as "cookie".
Where DataVisitors fits
DataVisitors is the privacy-friendly analytics tool from the t
Comments
No comments yet. Start the discussion.