PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteUse Browser.setCookie() for the default browser context or BrowserContext.setCookie() for a specific context, and pass each cookie as its own object argument. Puppeteer’s current documented cookie input is CookieData; the older Page.setCookie() API is marked obsolete. Set the cookie on the same context as the page that needs to send it.
Set a cookie before navigating
Create a browser context, set the cookie on that context, then create or use a page in that context. The example below uses an isolated context so its cookies do not belong to the default context.
As an Amazon Associate I earn from qualifying purchases.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const context = await browser.createBrowserContext();
await context.setCookie({
name: 'session',
value: 'example-value',
domain: 'example.com',
path: '/',
httpOnly: true,
secure: true,
sameSite: 'Lax',
});
const page = await context.newPage();
await page.goto('https://example.com');
console.log(await context.cookies());
} finally {
await browser.close();
}
This follows the current Puppeteer pattern of setting cookies through a browser or browser context rather than through a page. See the Puppeteer cookies guide and the BrowserContext API reference.
Use the intended context
A browser context isolates storage, including cookies. If the target page belongs to a context you created, call that context’s setCookie(). Calling browser.setCookie() instead writes to the default browser context, not the separate context. The corresponding read and delete operations are available on browser contexts as well.
#1 Best Overall
Pass separate cookie objects, not an array
Both setters accept one or more cookie objects as arguments. For multiple cookies, pass them separately:
await context.setCookie(
{ name: 'session', value: 'example-value', domain: 'example.com', path: '/' },
{ name: 'preference', value: 'compact', domain: 'example.com', path: '/' },
);
Do not wrap the objects in an array as the sole argument. The official guide demonstrates multiple cookies in one call and reading them back afterward.
Rank #2
Choose cookie parameters deliberately
The current CookieData interface documents name and value as required. The fields below are optional; choose values based on the site and the requests you need to test, rather than applying one security policy to every cookie. Puppeteer’s surfaced reference is labeled v25.12.0; check your installed version and browser when relying on browser-specific fields.
Free tools Windows power users keep installed
One-click scans. No signup required.
| Parameter | Meaning and practical use |
|---|---|
name, value |
Required cookie name and value. |
domain |
Sets the cookie’s domain scope. Specify it when the cookie should apply to a particular domain. |
path |
Sets the path scope. Use a path appropriate to the pages that should receive the cookie. |
expires |
A numeric expiration date. Omit it for a session cookie; consult the installed version’s reference for the accepted representation and behavior. |
httpOnly |
Use true when page JavaScript should not read the cookie. |
secure |
Use true for a cookie intended to be sent only over HTTPS. |
sameSite |
Controls the cookie’s SameSite behavior. Select the documented value appropriate to the navigation and request scenario you are testing. |
priority |
Cookie priority; the reference documents this as Chrome-only. |
sourceScheme |
Source scheme information; the reference documents this as Chrome-only. |
partitionKey |
Partitioning information. The documented semantics vary by browser: the reference associates it with the top-level site in Chrome and describes source-origin matching for Firefox. |
The current browser-level type is CookieData. A separate CookieParam reference belongs to the page-level API and includes a url field, which can affect default domain, path, and source-scheme values. Do not treat that legacy page-level input type as the preferred setter for current code.
Read and remove cookies
After setting a cookie, inspect the storage on the same context to verify that it was accepted:
const cookies = await context.cookies();
console.log(cookies);
The official guide also demonstrates reading cookies through browser.cookies() for the default context. For cleanup, BrowserContext documents deleteCookie() and deleteMatchingCookies(); use the context that owns the cookie. The page-level cookie APIs are deprecated in favor of browser and context methods. See the Browser.setCookie(), BrowserContext, and Page.setCookie() references.
Rank #4
Common problems and fixes
- The page does not receive the cookie: Confirm the cookie was set on the same context as the page, and check that its domain and path cover the destination URL.
- The cookie appears absent after navigation: Read it back with
context.cookies()and check its scope and security fields. In particular, an HTTPS-only cookie should be tested against an HTTPS URL. - Code passes an array to
setCookie(): Pass cookie objects as separate arguments instead. - Code uses
page.setCookie(): Replace it withcontext.setCookie()orbrowser.setCookie(), according to the page’s context. Puppeteer marks the page setter obsolete. - A browser-specific field has no expected effect: Check support in the installed Puppeteer and browser versions, especially for
priority,sourceScheme, and partitioning. - A cookie disappears when the context is recreated: A cookie without
expiresis a session cookie; use an appropriate expiration when persistence is required.
Or skip the browser setup
If your goal is to capture a website rather than run browser automation yourself, ScreenshotNeo is a screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF; the API also offers options for cookie values and other browser settings. For the full parameter list, see the ScreenshotNeo documentation.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers indicating the page verdict and billing status. Its MCP server provides screenshot and PDF tools for AI agents. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Which Puppeteer version should I check before using these fields?
Check the Puppeteer version installed in your project: the API reference labels surfaced for CookieData and BrowserContext are v25.12.0, while CookieParam is labeled v25.11.0. Those documentation labels do not establish which version your project uses.
Quick Recap
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.




