//cохраняю куки chrome.cookies.set({ url: "http://ru.stackoverflow.com/", name: "test", value: JSON.stringify({link: "OK" })}); //извлекаю куки function getCookies(domain, name, callback) { chrome.cookies.get({"url": domain, "name": name}, function(cookie) { if(callback) { callback(cookie.value); } }); } var check_cookies = getCookies("http://ru.stackoverflow.com/", "test", function(id) { console.log("id: " + id); }); //если кук нет, выполнить действие if (!check_cookies){ выполнить действие } 

You need to check if there are any saved cookies for the site (the contents of the cookies are not important, their presence is important).

  • There is no such method in api , which means you will have to create it yourself. I do not know exactly your situation, but you need to get cookies and already check whether they are or whether they have something that you need. - user220409
  • @olmerdale, I need to check if they exist at all - Forkildney65

2 answers 2

Natively, you can check for a cookie like this:

 if (chrome.cookie.indexOf("check_cookies") >= 0) { // если куки были, то... } 
     chrome.cookies.get({ url: "http://ru.stackoverflow.com/", name: "test" }, function (cookie) { if (!cookie) { // выполнить действие; console.log('Can\'t get cookie!'); } else { console.log(cookie.value); } });