I am developing a Firefox extension and need access to a specific cookie from a specific domain. I have this code that retrieves all cookies for all domains, as I can only request the cookie I'm looking for.
var {Cc, Ci} = require("chrome");
var cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager);
var count = cookieManager.enumerator;
while (count.hasMoreElements()){
var cookie = count.getNext();
if (cookie instanceof Ci.nsICookie){
console.log(cookie.host);
console.log(cookie.name);
console.log(cookie.value);
}
}
To summarize, I can find the cookie I'm looking for with the code above, but I don't want it to repeat all cookies from all domains.
source
share