October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Puppeteer Cookie Partition Keys Explained

Puppeteer cookie partition keys identify the top-level-site context for partitioned cookies. Learn what sourceOrigin means, where to pass partitionKey, and how Chrome and Firefox differ.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Puppeteer, a cookie partition key identifies the top-level-site context in which a partitioned cookie is available. In Chrome, Puppeteer calls the key’s main field sourceOrigin; it maps to the Chrome DevTools Protocol’s topLevelSite. The key is context, not another name for the cookie’s domain.

What a cookie partition key means

Chrome’s CHIPS model gives an opted-in third-party cookie a separate context for each top-level site. The cookie is double-keyed: by the setting site’s host key and by the partition key, which represents the top-level site associated with the request that set the cookie. As Chrome explains, “A partitioned third-party cookie is tied to the top-level site where it’s initially set and cannot be accessed from elsewhere.” Chrome’s CHIPS documentation describes the model and its intended isolation.

For example, an embedded service at widget.example can have one partitioned cookie when used on shop.example and a different one when used on news.example. The cookie is not thereby shared across unrelated top-level sites. This makes partitioned state useful for an embedded service that needs separate state per site, rather than for carrying one third-party cookie everywhere.

How Puppeteer represents the key

Puppeteer’s CookiePartitionKey reference (labelled Version 25.12.0) describes an object with these fields:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • sourceOrigin: the top-level-site value. The reference says this is the site of the top-level URL the browser was visiting at the start of the request to the endpoint that set the cookie. In Chrome, it maps to CDP’s topLevelSite.
  • hasCrossSiteAncestor: an optional boolean indicating whether the cookie has ancestors that are cross-site to that top-level site. Puppeteer documents this field as Chrome-only.

Although the name sourceOrigin sounds like the origin of the embedded cookie-setting service, in this Puppeteer interface it describes the top-level-site context. Chromium’s extensions schema uses the name topLevelSite for the corresponding concept: Chromium cookies API schema.

Where to pass partitionKey in Puppeteer

Puppeteer documents an optional partitionKey in both browser-level CookieData and page-level CookieParam. The browser-level reference is labelled Version 25.12.0; the page-level reference is labelled Version 25.11.0. Those are separate parameter shapes for different API surfaces—do not assume that every cookie-setting method accepts both shapes. Check the method and types for the Puppeteer version installed in your project.

Surface Role Documented partition-key behavior
CookiePartitionKey Key interface In Chrome, sourceOrigin maps to the top-level site; hasCrossSiteAncestor is optional and Chrome-only. Puppeteer reference.
CookieData Browser-level cookie parameter object Optional partitionKey, accepted as a CookiePartitionKey or string; Chrome matches it to the top-level site where the partitioned cookie is available. Puppeteer reference.
CookieParam Page-level cookie parameter object Optional partitionKey. Puppeteer documents different matching semantics for Firefox; its url can also affect default domain, path, and source scheme. Puppeteer reference.

Set a partitioned cookie using browser-level CookieData

This example uses the browser-context cookie API with a browser-level cookie object. The example assumes the installed Puppeteer version exposes BrowserContext.setCookie with CookieData; verify the method signature against your installed version. Replace the example domains with a real top-level site and embedded service you control. The cookie must be Secure, so use HTTPS.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({ headless: true });
try {
  const context = await browser.createBrowserContext();
  const page = await context.newPage();

  // The top-level site whose partition should contain the cookie.
  await page.goto('https://shop.example', { waitUntil: 'domcontentloaded' });

  await context.setCookie({
    name: '__Host-widget-session',
    value: 'example-value',
    url: 'https://widget.example',
    secure: true,
    path: '/',
    sameSite: 'None',
    partitionKey: {
      sourceOrigin: 'https://shop.example',
      hasCrossSiteAncestor: true,
    },
  });

  // Navigate to a page on the same top-level site that embeds widget.example
  // to test whether the embedded service receives its partitioned cookie.
  await page.goto('https://shop.example/page-with-widget', {
    waitUntil: 'domcontentloaded',
  });
} finally {
  await browser.close();
}

The cookie’s url identifies the embedded service, while partitionKey.sourceOrigin identifies the top-level-site context. Keep these roles distinct. If the request that sets the cookie has no cross-site ancestor, use the appropriate value for hasCrossSiteAncestor; do not set it reflexively. The Puppeteer interface marks it optional, and documents it as Chrome-only.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CHIPS cookie requirements and boundaries

Chrome’s CHIPS guidance requires Secure on partitioned cookies and recommends the __Host prefix. Its example cookie is:

Set-Cookie: __Host-name=value; Secure; Path=/; SameSite=None; Partitioned;

The equivalent documented JavaScript cookie string is:

Document.cookie="__Host-name=value; Secure; Path=/; SameSite=None; Partitioned;"

These are Chrome’s server-header and JavaScript examples, not Puppeteer method calls. Puppeteer’s cookie parameter uses a partitionKey field to identify the context; use the cookie fields supported by the particular API method you call. CHIPS is for isolated per-top-level-site state, not for sharing one cookie across unrelated sites. Chrome’s documentation also notes that its described Related Website Sets design relies on the Storage Access API and does not integrate with CHIPS partitioning.

Browser differences and version caveats

Do not carry Chrome assumptions over to Firefox. Puppeteer’s CookieParam documentation says Firefox matches the partition key to the source origin in PartitionKey, whereas Chrome uses top-level-site semantics. The same reference documents hasCrossSiteAncestor as Chrome-only.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Chrome’s extensions API is a separate interface: its chrome.cookies reference marks partition-key filtering or modification as Chrome 119+ and getPartitionKey() as Chrome 132+. Those markers apply to the extensions API; they do not establish a minimum Puppeteer version. Use the documentation and TypeScript definitions for the exact Puppeteer version and browser you run.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify behavior in the right context

  1. Load the intended top-level site over HTTPS.
  2. Set the cookie for the embedded service with a partition key for that top-level site.
  3. Visit a page on that same top-level site that embeds the service, then check the request or browser cookie state.
  4. Repeat with a different top-level site. A partitioned cookie should not be treated as the same shared third-party state there.

For a controlled check, compare the embedded service’s behavior under each top-level site, rather than merely checking that a cookie with a matching name exists. The partition key is part of the cookie context.

Troubleshooting

  • The cookie is rejected or missing: confirm the cookie is set over HTTPS and includes the required Secure attribute. Chrome’s CHIPS example also uses SameSite=None, Path=/, and Partitioned; for Puppeteer, check that you are using the right parameter shape for the API method.
  • The cookie appears on one site but not another: that is expected isolation when the top-level-site partition differs. Set or inspect the cookie in the top-level context where the embedded service needs it.
  • The TypeScript object is rejected: verify whether the called method expects browser-level CookieData or page-level CookieParam, and consult the installed Puppeteer version’s type definitions. The references document both fields but do not imply every method takes both shapes.
  • Firefox behaves differently: account for Puppeteer’s documented Firefox source-origin matching semantics. Do not expect Chrome’s sourceOrigin-to-topLevelSite mapping or Chrome-only ancestor field to transfer unchanged.
  • A browser extension example does not match Puppeteer: chrome.cookies is an extension API with its own version availability; its API version markers do not specify Puppeteer support.

Or skip the browser setup

If your goal is a clean screenshot of a page rather than setting or debugging its cookie partition behavior, ScreenshotNeo can return an image or PDF with one GET request. The service removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 shots a month with no card, and paid plans start at $5 for 3,000.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://shop.example -o shot.webp

See the ScreenshotNeo API documentation for parameters and response details. Sign up for 1,000 free screenshots a month, with no card required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.