cookies.getAllCookieStores()
语法
js
let gettingStores = browser.cookies.getAllCookieStores()
参数
无。
返回值
一个 Promise
,会兑现一个表示所有现有 cookie 存储的 cookies.CookieStore
对象的数组。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getAllCookieStores |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- See implementation notes.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
示例
在下面的代码片段中,getAllCookieStores()
方法用于检索浏览器中当前可用的所有 cookie 存储,并打印每个 cookie 存储的 ID,以及当前共享对应的 cookie 存储的标签页。
js
function logStores(cookieStores) {
for (const store of cookieStores) {
console.log(`Cookie 存储:${store.id}\n标签页 ID:${store.tabIds}`);
}
}
browser.cookies.getAllCookieStores().then(logStores);
cookieStores
数组的每个成员都是一个 cookies.CookieStore
对象。
备注:
此 API 基于 Chromium 的 chrome.cookies
API。本文档源自 Chromium 代码中的 cookies.json
。