cookies.getAll()

The getAll() method of the cookies API retrieves all cookies from a cookie store that match the details provided.

To use this method, an extension must have the "cookies" permission and relevant host permissions. See cookie permissions for more details.

This is an asynchronous function that returns a Promise.

Syntax

js
let getting = browser.cookies.getAll(
  details                // object
)

Parameters

details

An object containing details that are used to match cookies to retrieve. Included properties are as follows (see Cookie type for more information on these):

domain Optional

A string representing a domain that cookies must be associated with (they can be associated either with this exact domain or one of its subdomains).

firstPartyDomain Optional

A string representing the first-party domain with which the cookie to retrieve is associated.

This property must be supplied if the browser has first-party isolation enabled. If you pass null, cookies with any value for firstPartyDomain and cookies that do not have firstPartyDomain set are included in the results. See First-party isolation.

name Optional

A string representing a name that the cookies must have.

partitionKey Optional

An object defining which storage partitions to return cookies from:

  • If omitted, only cookies from unpartitioned storage are returned.
  • If included without topLevelSite, all cookies from partitioned and unpartitioned storage are returned.
  • If included with the specified topLevelSite, cookies from the specified partition storage are returned.

This object contains:

topLevelSite Optional

A string representing the first-party URL of the top-level site storage partition containing the cookies.

path Optional

A string representing a path — the cookies' path must be identical to this one.

secure Optional

A boolean — filters cookies by their secure property, allowing you to filter secure or non-secure cookies.

session Optional

A boolean — filters the cookies by their session property, allowing you to filter session or persistent cookies.

storeId Optional

A string representing the cookie store to retrieve cookies from. If omitted, the current execution context's cookie store is used.

url Optional

A string representing a URL that the retrieved cookies must be associated with.

Return value

A Promise that is fulfilled with an array of cookies.Cookie objects that match the properties given in the details parameter. Only unexpired cookies are returned. The cookies returned are sorted by path length, longest to shortest. If multiple cookies have the same path length, those with the earliest creation time are first.

Note: Before Firefox 133, Firefox returned the cookie sorted by creation time, with the earliest creation time first.

Examples

This example gets all of the cookies the browser has stored with the name "favorite-color". When the result is returned, the code prints the value of each result to the console.

js
function logCookies(cookies) {
  for (const cookie of cookies) {
    console.log(cookie.value);
  }
}

browser.cookies
  .getAll({
    name: "favorite-color",
  })
  .then(logCookies);

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
getAll
Chrome – Full support
Chrome 6 (Release date: 2010-09-02)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote If no URL is provided, cookies are retrieved only for URLs in currently opened tabs. In Chrome, this gets all cookies on a user's machine.
Firefox – Full support
Firefox 45 (Release date: 2016-03-08)
footnote
footnote Before version 52, the 'tabIds' list was empty and only cookies from the default cookie store were returned. From version 52 onwards, this has been fixed and the result includes cookies from private browsing mode and container tabs.
footnote From Firefox 133, sorts cookies according to RFC 6265, section 5.4. This means the cookie with the longest matching path is returned first: previously, the earliest created cookie was returned first.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Partial support
Safari 14 – 17.6 (Release date: 2020-09-16)
footnote Partial support
footnote Only the cookies in the default cookie store are retrieved.
footnote HttpOnly cookies are not retrieved.
Safari – Full support
Safari 18 (Release date: 2024-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 48 (Release date: 2016-08-02)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 15 – 17.6 (Release date: 2021-09-20)
footnote Partial support
footnote Only the cookies in the default cookie store are retrieved.
footnote HttpOnly cookies are not retrieved.
Safari on iOS – Full support
Safari on iOS 18 (Release date: 2024-09-16)
footnote Full support
firstPartyDomain
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 59 (Release date: 2018-03-13)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – Full support
Firefox for Android 59 (Release date: 2018-03-13)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
partitionKey
Chrome – Full support
Chrome 119 (Release date: 2023-10-31)
footnote Full support
Edge – Full support
Edge 119 (Release date: 2023-11-02)
footnote Full support
Firefox – Full support
Firefox 94 (Release date: 2021-11-02)
footnote Full support
Opera – Full support
Opera 105 (Release date: 2023-11-14)
footnote Full support
Safari – No support
Safari
footnote No support
Firefox for Android – Full support
Firefox for Android 94 (Release date: 2021-11-02)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.

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