files/en-us/web/api/cookiechangeevent/changed/index.md
{{securecontext_header}}{{APIRef("Cookie Store API")}}
The changed read-only property of the {{domxref("CookieChangeEvent")}} interface returns an array of the cookies that have been changed.
Note that this will exclude cookies which were created with an expiry date in the past, as these cookies are immediately deleted.
An array of objects containing the changed cookie(s). Each object contains the following properties:
name
value
domain
path
expires
secure
sameSite
SameSite values:
"strict"
"lax"
"none"
partitioned
true) or not (false). See Cookies Having Independent Partitioned State (CHIPS) for more information.In this example, when the cookie is set, the event listener logs the changed property to the console. The first item in that array contains an object representing the cookie that has just been set.
cookieStore.addEventListener("change", (event) => {
console.log(event.changed[0]);
});
const oneDay = 24 * 60 * 60 * 1000;
cookieStore.set({
name: "cookie1",
value: "cookie1-value",
expires: Date.now() + oneDay,
domain: "example.com",
});
{{Specifications}}
{{Compat}}