CookieStoreManager - Web APIs | MDN

Instance methods

CookieStoreManager.getSubscriptions()

Returns a Promise which resolves to a list of the cookie change subscriptions for this service worker registration.

CookieStoreManager.subscribe()

Subscribes to changes to cookies. It returns a Promise which resolves when the subscription is successful.

CookieStoreManager.unsubscribe()

Unsubscribes the registered service worker from changes to cookies. It returns a Promise which resolves when the operation is successful.

Examples

In this example, the ServiceWorkerRegistration represented by registration is subscribing to change events on the cookie named "cookie1" with a scope of "/path1".

js

const subscriptions = [{ name: "cookie1", url: `/path1` }];
await registration.cookies.subscribe(subscriptions);

If the ServiceWorkerRegistration has subscribed to any cookies, then getSubscriptions() will return a list of cookies represented by objects in the same format as used for the original subscription.

js

const subscriptions = await self.registration.cookies.getSubscriptions();

Specifications

Specification
Cookie Store API
# cookiestoremanager

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.