CookieStore.onchange

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

The onchange EventHandler of the CookieStore interface fires when a change is made to any cookie.

Syntax

CookieStore.onchange = function() { ... }
CookieStore.addEventListener('change', function() { ... })

Examples

In this example we listen for changes using the onchange event handler.

cookieStore.onchange = function() {
    console.log('1 change event');
};

In this example we listen for changes using addEventListener().

cookieStore.addEventListener('change', (event) => {
  console.log('1 change event');
});

Specifications

Specification
Cookie Store API
# dom-cookiestore-onchange

Browser compatibility

BCD tables only load in the browser