Use the browser.cookies API to query and modify cookies, and to be notified when they change.

Permissions: cookies

Not allowed in: Content scripts, Devtools pages

_GetAllDetails
_GetDetails
_OnChangedChangeInfo
_RemoveDetails
_RemoveReturnDetails
_SetDetails
CookieStore
PartitionKey
OnChangedCause
SameSiteStatus
onChanged
get
getAll
getAllCookieStores
remove
set
OnChangedCause:
    | "evicted"
    | "expired"
    | "explicit"
    | "expired_overwrite"
    | "overwrite"

The underlying reason behind the cookie's change. If a cookie was inserted, or removed via an explicit call to cookies.remove, "cause" will be "explicit". If a cookie was automatically removed due to expiry, "cause" will be "expired". If a cookie was removed due to being overwritten with an already-expired expiration date, "cause" will be set to "expired_overwrite". If a cookie was automatically removed due to garbage collection, "cause" will be "evicted". If a cookie was automatically removed due to a "set" call that overwrote it, "cause" will be "overwrite". Plan your response accordingly.

SameSiteStatus: "no_restriction" | "lax" | "strict"

A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set without a 'SameSite' attribute, 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'.

onChanged: WebExtEvent<
    (changeInfo: browser.cookies._OnChangedChangeInfo) => void,
>

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".

  • Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned.

    Parameters

    Returns Promise<Cookie>

  • Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first.

    Parameters

    • details: _GetAllDetails

      Information to filter the cookies being retrieved.

    Returns Promise<Cookie[]>

  • Lists all existing cookie stores.

    Returns Promise<CookieStore[]>

  • Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.

    Parameters

    Returns Promise<Cookie>