CookieStore: delete() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Service Workers.

The delete() method of the CookieStore interface deletes a cookie with the given name or options object. The delete() method expires the cookie by changing the date to one in the past.

Syntax

js
delete(name)
delete(options)

Parameters

This method requires one of the following:

name Optional

A string with the name of a cookie.

Or

options Optional

An object containing:

name

A string with the name of a cookie.

domain Optional

A string with the domain of a cookie. Defaults to null.

path Optional

A string containing a path. Defaults to /.

partitioned Optional

A boolean value that defaults to false. Setting it to true specifies that the cookie to delete will be a partitioned cookie. See Cookies Having Independent Partitioned State (CHIPS) for more information.

Return value

A Promise that resolves with undefined when deletion completes.

Exceptions

SecurityError DOMException

Thrown if the origin can not be serialized to a URL.

TypeError

Thrown if deleting the cookie represented by the given name or options fails.

Examples

In this example, a cookie is deleted by passing the name to the delete() method.

js
const result = await cookieStore.delete("cookie1");

console.log(result);

Specifications

Specification
Cookie Store API
# dom-cookiestore-delete

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
delete
partitioned option

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support