Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Puppeteer CookieData: Fields, Contexts, and How to Set Cookies

Puppeteer CookieData defines browser-level cookie properties. See each field, compare CookieParam, and set cookies in the intended browser context.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CookieData is Puppeteer’s parameter object for setting cookies through the browser-level cookies API. It carries the cookie name and value, scope, lifetime, security flags, same-site setting, and optional browser-specific metadata. Choose a BrowserContext deliberately: cookies belong to that context’s isolated storage, while Browser cookie methods are shortcuts for the default context.

CookieData fields at a glance

The Puppeteer 25.12.0 API reference defines CookieData for the browser-level cookie API. The object describes cookie properties; the browser context receiving it determines which isolated browser storage holds the cookie.

As an Amazon Associate I earn from qualifying purchases.

Field Meaning Notes
name The cookie’s name. Required by the interface.
value The cookie’s value. Required by the interface.
domain The domain scope for the cookie. Optional field.
path The path scope for the cookie. Optional field.
expires The cookie’s expiration date. Optional; when omitted, the reference describes the cookie as a session cookie.
httpOnly Whether the cookie has the HttpOnly flag. Optional boolean.
secure Whether the cookie has the Secure flag. Optional boolean.
sameSite The cookie’s same-site setting. Optional CookieSameSite value.
partitionKey Partition key for a partitioned cookie. Optional; browser-specific matching behavior applies.
priority Cookie priority metadata. Optional; Puppeteer documents support only in Chrome.
sourceScheme Scheme metadata for the cookie’s source. Optional; Puppeteer documents support only in Chrome.

Partitioning and browser-specific fields

Puppeteer’s reference describes partitionKey matching differently by browser: in Chrome it matches the top-level site where the partitioned cookie is available; in Firefox it matches the source origin in the partition key. The same reference documents priority and sourceScheme as Chrome-only. Check the documentation version and browser you run before relying on these optional fields.

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.

CookieData versus CookieParam

CookieData and CookieParam are related types, but they are attached to different API levels. The CookieParam reference describes the parameter for page-level cookie setting and includes an optional url. That URL can affect the cookie’s default domain, path, and source scheme. CookieData is used with the browser-level cookies API instead; do not assume that an object intended for one API has identical defaults or behavior in the other.

#1 Best Overall
Sale
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.
Question CookieData CookieParam
API level Browser-level cookies API. Page-level cookie-setting API.
URL input No URL behavior identified in the CookieData field reference. Optional url; it can influence default domain, path, and source scheme.
When to select it When setting cookies using browser or context cookie methods. When using the page-level cookie method.

For exact signatures and fields, use the API documentation matching the Puppeteer version installed in your project. The available references include versions 25.11.0 and 25.12.0 as well as a next guide, so a type or signature seen in one version should not be assumed to apply unchanged to another.

Set a cookie in the intended context

Puppeteer’s cookie guide covers getting, setting, and deleting cookies. The browser-level setCookie(...cookies) method accepts one or more CookieData objects, and equivalent cookie methods are available on BrowserContext. A context isolates browser storage, including cookies and local storage. By contrast, Browser.cookies() and Browser.setCookie() are convenience methods for the default context.

Browser-level example using the default context

This example creates a browser, adds a session cookie to its default context using Browser.setCookie(), reads cookies, then deletes the cookie. It uses a placeholder value: provide a test or authorized cookie value rather than a real user’s session credential.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Logitech MK270 Full Size Wireless Keyboard and Mouse Combo - Black | Full size keyboard with spill-resistant design, compact ambidextrous mouse, connect via single included USB-A Nano Receiver
  • Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
  • Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
  • Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
  • Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
  • Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    await browser.setCookie({
      name: 'theme',
      value: 'dark',
      domain: 'example.com',
      path: '/',
      httpOnly: true,
      secure: true,
      sameSite: 'Lax'
    });

    const cookies = await browser.cookies();
    console.log(cookies);

    await browser.deleteCookie({
      name: 'theme',
      domain: 'example.com',
      path: '/'
    });
  } finally {
    await browser.close();
  }
})();

The omitted expires makes this a session cookie according to the field reference. The code’s sameSite value is an example of the optional CookieSameSite setting; confirm the accepted values and method signatures in your installed Puppeteer version.

Use an explicit BrowserContext for isolated state

When a browser has multiple independent sessions, operate on the context that owns the intended session rather than relying on a browser convenience method that targets the default context.

const context = await browser.createBrowserContext();

await context.setCookie({
  name: 'theme',
  value: 'dark',
  domain: 'example.com',
  path: '/',
  secure: true
});

const cookiesInThisSession = await context.cookies();
console.log(cookiesInThisSession);

Keep the context reference associated with the session that needs the cookie. A cookie placed in a different context does not become part of this context’s isolated storage.

Rank #3
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black | Full-size keyboard, spill-resistant, curved space bar, Windows PC and laptops compatible
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*

Choose fields and scope for the task

  • Lifetime: omit expires for a session cookie as described by Puppeteer’s field reference; supply an expiration when the cookie should have a specified lifetime.
  • Domain and path: set the scope appropriate to the site paths and hosts that need the cookie. For page-level CookieParam, a supplied url can affect default domain, path, and source scheme.
  • Security flags: set httpOnly and secure according to the cookie’s intended properties and the environment where it will be used.
  • Same-site behavior: use the supported CookieSameSite value suitable for the use case; this article does not attempt to enumerate all browser-standard compatibility rules.
  • Partitioned cookies: use partitionKey only with awareness of Puppeteer’s documented browser-specific matching behavior.
  • Optional Chrome metadata: treat priority and sourceScheme as Chrome-specific per Puppeteer’s documentation.

Common problems and fixes

The cookie is missing when you inspect a page

Check which context received the cookie. Browser.setCookie() targets the default context; if the page belongs to another context, set and inspect the cookie through that page’s BrowserContext.

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

The cookie has an unexpected lifetime

Check whether expires was omitted. Puppeteer’s CookieData reference describes an omitted expiration as a session cookie.

The cookie’s domain or path is not what you expected

Confirm which API you called. A page-level CookieParam can include url, which affects default domain, path, and source scheme. The browser-level CookieData API uses its own object and should not be presumed to apply those URL-derived defaults.

Rank #4
Sale
Redragon K521 Upgrade Rainbow LED Gaming Keyboard, 104 Keys Wired Mechanical Feeling Keyboard with Multimedia Keys, One-Touch Backlit, Anti-Ghosting, Compatible with PC, Mac, PS4/5, Xbox
  • 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
  • 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
  • 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
  • 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
  • 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use

An optional field does not behave across browsers

Check support before using partitionKey, priority, or sourceScheme. Puppeteer specifically documents different partition-key matching for Chrome and Firefox, and Chrome-only support for the latter two fields.

Examples do not match the installed package

Verify the API docs for the version installed in your project. Puppeteer documentation includes versioned API references and a next guide; do not assume that a sample written against another version has identical signatures.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to capture a website rather than manipulate its browser cookies, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF, and it can remove cookie/consent banners, newsletter popups, and chat widgets before the capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents.

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

See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month with no card.

Best Value
Sale
Logitech K270 Full Size Wireless Keyboard for Windows - Black | Full-size keyboard with number pad, 8 multimedia keys, includes USB-A receiver, 2-year battery, compatible with PC, laptop
  • All-day Comfort: This USB keyboard creates a comfortable and familiar typing experience thanks to the deep-profile keys and standard full-size layout with all F-keys, number pad and arrow keys
  • Built to Last: The spill-proof (2) design and durable print characters keep you on track for years to come despite any on-the-job mishaps; it’s a reliable partner for your desk at home, or at work
  • Long-lasting Battery Life: A 24-month battery life (4) means you can go for 2 years without the hassle of changing batteries of your wireless full-size keyboard
  • Simply plug the USB receiver into a USB port on your desktop, laptop or netbook computer and start using the keyboard right away without any software installation
  • Simply Wireless: Forget about drop-outs and delays thanks to a strong, reliable wireless connection with up to 33 ft range (5); K270 is compatible with Windows 7, 8, 10 or later

Frequently Asked Questions

Can I pass multiple cookies to Puppeteer’s browser-level setCookie method?

Yes. Puppeteer documents browser-level setCookie(...cookies) as accepting one or more CookieData objects.

Does CookieData support partitionKey in every browser the same way?

No. Puppeteer documents Chrome matching the top-level site where the partitioned cookie is available and Firefox matching the source origin in the partition key.

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 *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.