cookies.CookieStore
cookies
API 的 CookieStore
型別代表瀏覽器中的 cookie 存放空間。
不同瀏覽模式(browsing mode)的視窗,有不同的 cookie 存放空間:例如隱私/隱身模式的視窗,會使用來自非隱私/隱身模式視窗的個別 cookie 存放空間。
型別
瀏覽器相容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
CookieStore | |||||||
id | |||||||
incognito | |||||||
tabIds |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
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.
示例
在以下程式碼片段內,cookies.getAllCookieStores()
用來查找瀏覽器內,所有目前能用 cookie 存放空間,並列出每個 cookie 存放空間的 ID、還有分享此 cookie 存放空間的頁籤。
js
function logStores(cookieStores) {
for (store of cookieStores) {
console.log(`Cookie store: ${store.id}\n Tab IDs: ${store.tabIds}`);
}
}
var getting = browser.cookies.getAllCookieStores();
getting.then(logStores);
備註:
此 API 基於 Chromium 的 chrome.cookies
API 而來,文件改作自 Chromium 程式碼裡的 cookies.json
。
Microsoft Edge 的相容資訊來自微軟公司,原文以創用 CC 姓名標示 3.0 美國版條款授權大眾使用。