CookieStore: delete() method

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

Note: This feature is available in Web 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.




This method requires one of the following:

name Optional

A string with the name of a cookie.


options Optional

An object containing:


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.

Note: The url option enables the modification of a cookie scoped under a particular URL. Service workers can obtain cookies that would be sent to any URL under their scope. From a document you may only obtain the cookies at the current URL, so the only valid URL in a document context is the document's URL.

Return value

A Promise that resolves with undefined when deletion completes.


SecurityError DOMException

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


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


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

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



Cookie Store API
# dom-cookiestore-delete

Browser compatibility

BCD tables only load in the browser