0

I am making a chrome extension and I have no clue as for getting ALL cookies', cause for some reason I can't reach the HttpOnly and session ones, and document.cookie obviously doesn't provide me the httponly and session ones, so I wanted to know how I can do that.

I have that code :

"permissions": [ "activeTab", "webRequest", "cookies" ]

And in my attempt to get all cookies from the current website including httponly and session ones I wrote:

  var cock = "";


chrome.cookies.getAll({"url":tab[0].url},function (cookie){


    for(i=0;i<cookie.length;i++){

        cock+= cookie[i];
    }

});

alert(cock);

But the code above didn't work at all as it was supposed to show all cookies but doesn't even work.

I would be glad to receive help on this one.

1 Answers1

0

To use the chrome.cookies API you need to add host permissions for the domains for which you want to get the cookies. The following sample and phrase are in the docs:

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

If host permissions for this URL are not specified in the manifest file, the API call will fail.

If you want to be able to get cookies for any domain you'll need to use the <all_urls> permission.

rsanchez
  • 14,467
  • 1
  • 35
  • 46
  • Listen I have added that to the code but that still doesn't work, var cock = ""; chrome.cookies.getAll({"url":tab[0].url},function (cookie){ for(i=0;i – bruce willson Mar 10 '16 at 19:52
  • @brucewillson you should put the `alert` before `});`. Also I don't know what you mean by "it breaks the JS". – rsanchez Mar 10 '16 at 20:17
  • That doesn't work as well, listen I need access to HttpOnly cookies, how do I do that ? – bruce willson Mar 11 '16 at 16:13