P
P
p3trukh1n2019-06-13 21:02:01
JavaScript
p3trukh1n, 2019-06-13 21:02:01

Chrome.cookies.getAll returns empty array, how to fix?

I execute chrome.cookies.getAll - with callback=console.log, and outputs an empty array.
manifest.json:

{
  "name": "Cookies changer",
  "description": "Cookies changer",
  "version": "1.0",
  "manifest_version": 2,
  "permissions": [
    "https://www.vk.com/",
    "storage",
    "cookies"
  ],
  "browser_action": {
    "default_popup": "index.html",
    "default_icon": "cookies.png"
  }
}

popup.js:
(function() {
  chrome.cookies.getAll({}, result => {
    console.log(result); // Выводит Array(0) - пустой массив
  });
})();

And believe me, popup.js is included in popup.html

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Chefranov, 2019-06-13
@p3trukh1n

chrome.cookies.getAll seems to work only in background.js
But you did not pass the parameters from where to get cookies

chrome.cookies.getAll({ domain: "vk.com" }, cookies => {
  console.log(cookies);
});

In the manifest, remove www.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question