October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Delete Matching Cookies with Puppeteer

Use Puppeteer's context-scoped matching deletion method, and verify the filter schema against the version installed in your project.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use BrowserContext.deleteMatchingCookies(...filters) to delete selected cookies from one Puppeteer browser context without clearing cookies in other contexts. The method returns a promise, so await it. Before choosing filters, check the DeleteCookiesRequest type in the Puppeteer version installed in your project: the API reference names that type but does not enumerate its fields or matching rules.

Choose the browser context that owns the cookies

Cookies belong to a browser context, and contexts have isolated storage. A call on one context does not clear cookies in every context. If the page whose cookies you want to change is available, get its context and call the method there:

As an Amazon Associate I earn from qualifying purchases.

const context = page.browserContext();
await context.deleteMatchingCookies(...filters);

Here, filters must be one or more filter objects accepted by the DeleteCookiesRequest type in your installed Puppeteer release. The code shows the method and scope, not a particular filter schema.

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

If you create a separate context for a task, use that same context for the page and cookie deletion. Puppeteer’s BrowserContext documentation describes contexts as isolated user contexts and shows creating a context, opening a page in it, and closing the context when finished.

Use filters supported by your installed Puppeteer version

The method reference documents the signature as deleteMatchingCookies(...filters: DeleteCookiesRequest[]): Promise<void> and says it deletes cookies matching the supplied filters in that browser context. It does not, in the reference available here, list the request type’s fields or define wildcard, partial-name, domain-normalization, or path-matching behavior. Do not assume those semantics.

Cookie data documented by Puppeteer includes a name, domain, path, and optional partition key. For partitioned cookies, Puppeteer’s CookieData reference describes the partition key as matching the top-level site. These are cookie data dimensions; they do not, by themselves, establish that every dimension is accepted by every release’s deletion filter.

  1. Check the Puppeteer package version used by the project and inspect its DeleteCookiesRequest type and matching-deletion reference.
  2. Build the filter object or objects using only fields and semantics established for that version.
  3. Pass those filters to the intended context’s deleteMatchingCookies call and await the promise.

The method reference currently identifies its API documentation as version 25.4.0, while the BrowserContext class reference identifies version 25.12.0. Those labels are documentation versions, not a compatibility guarantee for an arbitrary installed package. Check your own package rather than copying a filter shape from an unrelated release.

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

Use the Browser shortcut only for the default context

Browser.deleteMatchingCookies(...filters) is a shortcut for browser.defaultBrowserContext().deleteMatchingCookies(...filters). Use it when the default context is the intended storage area:

await browser.deleteMatchingCookies(...filters);

If the page belongs to a separately created context, use page.browserContext() and call the context method instead. The browser shortcut does not mean that all contexts are cleared. Puppeteer’s Browser class reference documents the default-context shortcut.

Inspect cookies and avoid the obsolete page method

To inspect cookies for a particular context, use that context’s cookies() method. The browser-level cookies() shortcut addresses the default context, as described in Puppeteer’s Browser.cookies() reference.

Do not build new code around Page.deleteCookie(). Puppeteer marks that page-level API obsolete and directs users to browser or context cookie APIs, including the matching-deletion methods. See the Page.deleteCookie() reference.

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

Troubleshoot matching deletion

  • The cookie remains: First verify that the page and deletion call use the same context. Then verify the filter fields and matching semantics against the installed version’s DeleteCookiesRequest type; do not infer partial matching or wildcard support.
  • The code rejects a filter: The filter shape may not match the installed release. Check that release’s type definition and API documentation rather than relying on a schema from a different version.
  • Unrelated cookies disappear: Confirm that the filter is as selective as intended and that the call targets the right context. The documented method deletes cookies matching its supplied filters; its exact matching semantics depend on the version-specific request definition.
  • TypeScript reports a type error: Compare the filter object with the installed package’s DeleteCookiesRequest type. The method reference names the type but does not list its fields in the available reference excerpt.
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 a screenshot rather than cookie-state control in your own browser automation, ScreenshotNeo offers a one-request screenshot API. It accepts consent banners as a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server provides screenshot tools for AI agents.

Example cURL request (see the ScreenshotNeo API documentation):

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’s free plan.

Frequently Asked Questions

Does deleting matching cookies return the deleted cookies?

No. Puppeteer’s documented return type is Promise<void>.

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

Can I use the same deletion call to clear cookies in every browser context?

No. The context method is scoped to the context on which it is called.

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 *

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
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.