Access specific cookies by domain/name in Firefox extension

前端 未结 1 611
余生分开走
余生分开走 2021-01-13 04:14

I am developing a Firefox extension and need to access a specific cookie from a specific domain. I have this code which fetches all cookies for all domains, how do I request

相关标签:
1条回答
  • 2021-01-13 05:05

    You can use nsICookieManager2 interface (the original nsICookieManager interface was frozen and couldn't be changed which is why this extended version was created):

    var cookieManager = Cc["@mozilla.org/cookiemanager;1"]
                          .getService(Ci.nsICookieManager2);
    var count = cookieManager.getCookiesFromHost("example.com");
    

    Note: the concept of frozen interfaces was dropped in Gecko 2.0 (Firefox 4). Since then some interfaces similar to nsICookieManager/nsICookieManager2 have been unified - so in a future Firefox version nsICookieManager2 might go away as well, all the functionality will be exposed on nsICookieManager then.

    0 讨论(0)
提交回复
热议问题