As third-party cookie phaseouts accelerate across the web, cross-site embedded widgets—such as payment iframes, customer support chat modules, and enterprise analytics dashboards—face severe state persistence barriers. Cookies Having Independent Partitioned State (CHIPS) resolves this challenge by partitioning cookies by top-level site using the Partitioned attribute. However, modern Single Page Applications (SPAs) and Progressive Web Apps (PWAs) frequently coordinate network traffic through Service Workers, where unpartitioned cookie assumptions can break API authentication. In Google Chrome, configuring partitioned cookie propagation within Service Workers ensures compliant, privacy-preserving session management.
Understanding CHIPS and the Partitioned Cookie Attribute
CHIPS introduces a dedicated cookie attribute that binds cookies to the top-level origin where the frame is embedded:
Set-Cookie: __Host-sid=xyz123; Secure; Path=/; SameSite=None; Partitioned;- Double-Keyed Partitioning: A partitioned cookie stored when
app.example.comis embedded insidesite-a.comcannot be read whenapp.example.comis embedded insidesite-b.comor visited directly. - Service Worker Partitioning: In Chromium, Service Worker registrations originating from partitioned iframes are also partitioned, ensuring that worker-mediated
fetch()requests automatically inherit matching partitioned cookies.
Configuring Web Server Headers for CHIPS Delivery
Configure your API or authentication service to append the Partitioned directive to cross-site session cookies:
# Nginx server configuration for partitioned API cookies
location /api/v1/session {
add_header Set-Cookie "__Host-client-session=token_abc789; Secure; Path=/; SameSite=None; Partitioned; HttpOnly" always;
proxy_pass http://127.0.0.1:4000;
}
# Apache HTTP Server (.htaccess / virtual host)
Header always edit Set-Cookie "^(.*)$" "$1; Partitioned"
Note that the cookie must use the __Host- prefix (requiring Secure, Path=/, and omitting domain attributes) to satisfy strict CHIPS requirements.
Managing Partitioned Cookies in Service Worker Fetch Handlers
When intercepting network requests inside a Service Worker, ensure credentials are explicitly forwarded:
// service-worker.js
self.addEventListener('fetch', (event) => {
const url = new URL(event.request.url);
if (url.pathname.startsWith('/api/')) {
event.respondWith((async () => {
// Forward request with partitioned ambient credentials included
const modifiedRequest = new Request(event.request, {
credentials: 'include'
});
return await fetch(modifiedRequest);
})());
}
});
Auditing CHIPS Partitioning in Chrome DevTools
To inspect and audit partitioned cookies using Google Chrome:
- Open Google Chrome and navigate to the parent website embedding your partitioned service.
- Open Chrome DevTools by pressing Ctrl + Shift + I (or Option + Command + I on macOS).
- Switch to the Application tab and expand Cookies under the Storage tree.
- Select your embedded domain. Right-click the cookie table header and ensure Partition Key is enabled.
- Verify that your session cookie has a checkbox marked under the Partitioned column and displays the top-level site (e.g.
https://site-a.com) under the Partition Key column. - Inspect the Console tab to confirm no deprecation warnings are flagged for third-party cookie access.