Hello,
I am working on a Chrome extension that needs to access all cookies for some applications domain.
I am using the chrome.cookies.getAll API to retrieve the cookies, but I noticed that the result is different from what I see in the Developer Tools.
For example, when I try to get all cookies for Twitter using the following code:
chrome.cookies.getAll({}, cookies => {
const filteredCookies = cookies.filter(cookie =>
cookie.domain.endsWith(domain)
)
console.log(filteredCookies);
// Extract the cookie names
const cookieNames = filteredCookies.map((cookie) =>
cookie.name);
// Save the cookie names to storage
const storageKey = `${domain}:cookies`;
const storageValue = cookieNames;
const items = {};
items[storageKey] = storageValue;
chrome.storage.local.set(items, function () {
console.log("Cookies saved for domain " + domain);
resolve(filteredCookies);
});
});
I get a list of cookies that does not include some cookies that I can see in the "Application" tab of the Developer Tools.
The results I get from get all cookies:
[
"ab.storage.deviceId.a9882122-ac6c-486a-bc3b-fab39ef624c5",
"g_state",
"at_check",
"mbox",
"_ga",
"_ga_BYKEBDM7DS",
"_ga",
"_gid",
"guest_id",
"att",
"guest_id_marketing",
"guest_id_ads",
"gt",
"personalization_id",
"ct0",
"_twitter_sess"
]
But in the "application" tab in the dev tools I can see different data (screenshot attached)
(e.g the "auth_token" is missing from the getAll cookies method, but exists in the dev tools)
Could you please explain why this happens and how can I get all cookies for a domain, including the ones that are not returned by chrome.cookies.getAll?
Thank you for your help.