chrome.cookies.getAll returns an empty array

I’m working on a simple chrome extension that will delete all cookies from a domain with one click but for some reason, it’s not working. When I try to get all the cookies from the domain, it returns an empty array. What am I doing wrong?
Here’s the js script:

$("#fixTheCookiesButton").click(() => {
  // delete the cookies
  chrome.cookies.getAll({domain: ""}, (cookies) => {
    console.log("deleting " + cookies.length + " cookies")
    for(var i = 0; i < cookies.length; i++){
      console.log(i + " deleted")
        url: "" + cookies[i].path,
        name: cookies[i].name
    // some other stuff that isn't relevant here

and here's my manifest:

  "manifest_version": 2,
  "name": "FixYT",
  "version": "1.0",
  "description": "Fixes that YT cookie bug with one click",
  "browser_action": {
          "default_title": "FixYT",
          "default_popup": "popup.html"
  "permissions": [

I've tried looking around the internet but I can't find any solutions to this.

Handling multiple timers using cookies in javascript for chrome extension

I am making a chrome extension in which I need to record how much time user spends on a particular website, if it crosses certain specified time duration than user must be notified about that.

For this I am looking forward to use cookies to store duration of active tab(so that info stays even after closing browser) and expire cookies as soon as time allotted gets ‘0’. I know we can’t perform this with simply putting allotted time in expirationDate as timer for this will still be working while tab is not opened.

Can anyone please guide me how I can achieve this. I require different cookies for different websites and separately calculate the time duration of access of them.


               // Iterating through all inputted web addresses that
               // are to be monitored
                for(var j = 0; j < l ; j++){

                var x = addresses[j];

                        // Iterating through all tabs
                        chrome.tabs.query({}, function(tabs) { 
                            for(var i = 0; i < tabs.length; i++){

                                // Checking if some url is matched
                                if (tabs[i].url.includes(x)) {
                                        var t = times[j].toString();
                                        var H = 0;
                                        H = parseInt(t.substr(0, 2));
                                        var M = 0;
                                        M = parseInt(t.substr(3, 2));

                                        // Getting the allotted time      
                                        var time = H * 60 * 60 + M * 60;

                                       // Don't know what to do here
                                       // with cookies to associate 
                                       // each web address with the respective time



Chrome extension get all tab cookies

Trying to get all cookies from the page, using chrome extension.

For example the page os

Here is my code:

chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
    var domain = getDomain(tabs[0].url);

        domain: domain
    }, function(cookies) {


This code will return all cookies (8) for domain
But the problem is when I’m opening the browser console I see cookies not only for domain:

enter image description here

Same situation is on google and other sites. So I’m having multiple domain cookies on one page. How to get ALL cookies on the page?

Thank for your time.

How does LastPass chrome extension remember logged in user after being opened in incognito mode?

I logged in to LastPass chrome extension in the regular browsing mode. Then I opened a new incognito tab and the LastPass extension still knows who I am. How did they do that? I need that exact behaviour for my chrome extension.

Firefox extension/addon does not store cookies

I’m working on an browser extension that authenticates with a remote server via XMLHttpRequests. In Firefox (59.0.2) I have the problem that the session cookie send by the server is not stored in the browser. When looking at the network traffic I get a Set-Cookie response from the server for every request:

Set-Cookie JSESSIONID=node01abks2u96hf84wt0i1uqwsb9879.node0;Path=/

but it seems that the cookie is never accepted or stored in the extension.

When looking at Chrome (where the extension is working) my extension includes this cookie in the request:

Cookie: io=jCX1X9rlaOhCqE0nAAAB JSESSIONID=node01abks2u96hf84wt0i1uqwsb9879.node0

However, this is not the case in Firefox. Why is Firefox is not including the cookie in the request? and why is it not storing the cookie?

chrome.cookie.get Incorrect cookies for domain

I am attempting to get the csrf token for a given domain, I have read that this can’t be done in a content script (i.e. can’t use chrome.* functions in content scripts) and am trying to do this in a background page.

For example, I have this code:

chrome.cookies.get({ 'name': 'csrf', 'url': '' }, function(c) {

This works, and I am able to get the csrf token cookie for the intended domain. However, this value is incorrect. If I compare the value to the csrf token directly in chrome for that domain, the values do not match. I also noticed that it appears as though I’m missing some cookies relevant to the domain. For example, using chrome.cookies.getAll I get back 2 cookies. If I inspect the cookies on the pertinent page on, I see 10 cookies. Where are the missing 8?

Does the background page operate in a different, isolated context to the chrome browser? Why don’t I see all of the cookies and why are my csrf cookie values incorrect?

Also, it seems like my csrf token value is always the same in the background script. Even after I login/logout of the page in chrome.

Here are the permissions from my manifest file:

"permissions": ["*://**", "cookies"]

Ajax request with a redirect, unable to get Cookies

I have an $.ajax request that hits and API. The API returns four cookies and then performs a (302) redirect.

  url: authUrl,
  type: 'post',
  mode: 'no-cors',
  dataType: 'text',
  data: dataObj,
.done(function (response) {
    let myCookies = document.cookie;

I’m trying to get the cookies inside the $.ajax, but the redirect causes the code in the .done to never execute. enter image description here

Even if I try to get the cookies in the console (where I can see the cookies and their values), I get nothing back.

This is happening inside a Chrome Extension, but even if I run this outside the extension I get the same result.

Set expirationDate in Chrome.cookie.set method

When setting an Expiration Date for a Cookie generated using the Chrome.cookie.set method:

                url: domain,
                name: name,
                value: "Hello, you!",
                expirationDate: + 21000

The expiration date for the resulting cookie is set with the following form:

enter image description here

The official documentation indicates that expirationDate is a Double (or “the number of seconds since the UNIX epoch”).

chrome extension request not returning with set-cookie header

I am working on a chrome extension for getting profile data from a website. I make a post request to the website using cookie values obtained from a previous page set-cookie value, like so:

const response = await request(options)
const cookie = response.headers['set-cookie']

I am using the request library.

For some reason running my function directly using node returns a response with a header that contains ‘set-cookie’ but running it from a chrome extension context returns a header without the ‘set-cookie’ value.

I have tried adding the “cookies” permission to my manifest to no avail.
I also tried a fix for some issue with the request library losing cookies during multiple redirects by setting the request option “followRedirect” to false

Show iframe in Chrome extension tab that does not have access to cookies?

In a tab owned by a Chrome extension I want to show a preview of a webpage URL. The only option I can see is an iframe. I do not want the iframe to have access to existing cookies created for the URLs domain or able to alter those cookies.

For example, if a user logged into the domain in another tab then launched my Chrome extension, I don’t want the iframe to be logged in either. Also, if the user logs in using the iframe, I don’t want this to carry over to new tabs.

I can see that by using WebRequest API I can block sending and receiving cookie headers but I can’t see how I can stop JavaScript cookies from being created. For example, I tested some iframes that include a “I agree to allow cookies, click to close” banner and the banner hidden state was being remembered between the iframe and a new tab which I don’t want.

I want the iframe to look correct in terms of a preview as much as possible so I don’t want stop all scripts from running and the origin restriction options break a lot of sites.