CookieStore: change event
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.
A change
event is fired at a CookieStore
object when a change is made to any cookie.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
cookieStore.addEventListener("change", (event) => { })
cookieStore.onchange = (event) => { }
Event type
A CookieChangeEvent
. Inherits from Event
.
Examples
To be informed when a cookie has changed, you can add a handler to the cookieStore
instance using addEventListener()
, like this:
cookieStore.addEventListener("change", (event) => {
console.log("1 change event");
});
Alternatively, you can use the onchange
event handler property to establish a handler for the change
event:
cookieStore.onchange = (event) => {
console.log("1 change event");
};
Specifications
Specification |
---|
Cookie Store API # intro-monitor |
Cookie Store API # dom-cookiestore-onchange |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
change event |
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