Access cookies from Google Chrome extension

Currently the best (the simplest) way to get site cookies in an extension is put this code in your background script:

chrome.cookies.get({ url: 'http://example.com', name: 'somename' },
  function (cookie) {
    if (cookie) {
      console.log(cookie.value);
    }
    else {
      console.log('Can\'t get cookie! Check the name!');
    }
});

So now you don’t need content script for this but don’t forget to include permissions into manifest:

"permissions": [
  "cookies",
  "*://*.example.com/*"
]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)