cookies.onChanged

Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit".

Syntax

browser.cookies.onChanged.addListener(function(
  changeInfo // object
) {...})
browser.cookies.onChanged.removeListener(listener)
browser.cookies.onChanged.hasListener(listener)

Events have three functions:

addListener(callback)
Adds a listener to this event.
removeListener(listener)
Stop listening to this event. The listener argument is the listener to remove.
hasListener(listener)
Check whether listener is registered for this event. Returns true if it is listening, false otherwise.

addListener syntax

Parameters

callback

Function that will be called when this event occurs. The function will be passed the following arguments:

changeInfo
object.

Additional objects

changeInfo

removed
boolean. True if a cookie was removed.
cookie
cookies.Cookie. Information about the cookie that was set or removed.
cause
cookies.OnChangedCause. The underlying reason behind the cookie's change.

Browser compatibility

EdgeFirefoxChromeOpera
Basic support?45.0Yes33
Firefox
Basic support48.0

Examples

Acknowledgements

This API is based on Chromium's chrome.cookies API. This documentation is derived from cookies.json in the Chromium code.

Document Tags and Contributors

 Contributors to this page: wbamberg
 Last updated by: wbamberg,