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.

You can use Puppeteer to put a cookie into a browser context, then check whether the browser actually sends it in a third-party request. Those are separate steps: context.setCookie() changes browser storage, but does not guarantee that privacy settings or the site will allow the cookie in an embedded or cross-site request.

Set a cookie in the context used by your test

For the current Puppeteer “Next” documentation, use the BrowserContext cookie methods when working in an isolated context. Create the page from that same context, set the cookie there, and inspect cookies there:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const context = await browser.createBrowserContext();
const page = await context.newPage();

// Use the actual cookie name, value, and domain for your authorized test.
await context.setCookie({
  name: 'example',
  value: 'test-value',
  domain: 'third-party.example',
  path: '/',
  secure: true,
  httpOnly: true,
  sameSite: 'None',
});

await page.goto('https://first-party.example');
console.log(await context.cookies());

await context.close();
await browser.close();

Replace the example domain and values with the cookie details for your test. The secure flag requires a secure context for sending, and httpOnly prevents access through page JavaScript; it does not prevent Puppeteer’s browser-context cookie API from managing the cookie.

Confirm storage and third-party delivery separately

The output from context.cookies() tells you what Puppeteer can see in that context’s cookie storage. It does not prove that a cookie was attached to a particular cross-site request or exposed to an embedded frame. Verify the actual request or frame behavior your test cares about; do not treat a successful storage write as proof of delivery.

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

The Puppeteer cookie guide describes setting and reading cookies by manipulating browser storage directly. Chrome’s documentation also describes a special extension-page exception for third-party cookie behavior, underscoring that context matters. The available documentation does not establish a universal Puppeteer switch that forces browsers or sites to accept third-party cookies. Policy can depend on browser, version, settings, and site behavior.

Choose the right cookie API and context

Use an isolated BrowserContext for an isolated test

Each BrowserContext has isolated storage, including cookies and localStorage. A cookie set in one context is not automatically shared with another. Create the page and set, read, or delete cookies through the context that owns the page under test.

Use Browser methods with the default context

If your page uses Puppeteer’s default browser context, the corresponding browser.cookies() and browser.setCookie() methods operate on that default context. Use context methods when your test explicitly creates an isolated context.

Avoid deprecated Page cookie methods

Puppeteer marks page.cookies() and page.setCookie() as deprecated and directs users to the Browser or BrowserContext methods instead.

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

Troubleshoot a cookie that is not sent

  • It appears in context.cookies() but not in the request: the storage write may have succeeded while browser policy, request context, or site behavior prevents delivery. Inspect the request and the relevant browser settings rather than repeating the write blindly.
  • The page and cookie use different contexts: create the page from the same context used for setCookie(). Context storage is isolated.
  • The cookie is rejected or omitted: check its domain, path, security attributes, and the target request’s scheme and context. SameSite=None does not override browser privacy controls.
  • Your code uses page.setCookie() or page.cookies(): migrate to context.setCookie(), context.cookies(), or their Browser equivalents.
  • The API signature differs from this example: the cited guide is labeled “Next,” and the API pages track Puppeteer’s main branch. Check the documentation for your installed Puppeteer release before relying on version-specific behavior.

Or skip the browser setup

If the task is to produce a clean screenshot rather than test cookie delivery in Puppeteer, ScreenshotNeo is a screenshot API that returns an image or PDF from one GET request. It accepts consent banners before capture and removes known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server lets AI agents use screenshot tools.

See the ScreenshotNeo API documentation. For example, this cURL request saves a WebP screenshot:

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

The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo.

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

Frequently Asked Questions

Can Puppeteer force third-party cookies to be accepted?

The cited Puppeteer documentation does not document a universal override that forces browser or site acceptance.

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

Is page.setCookie() deprecated?

Yes. Use the Browser or BrowserContext cookie methods instead.

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.