Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8501129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:07:24+00:00 2026-06-11T01:07:24+00:00

I am building and extension with Firefox’s Addon SDK (v1.9). My application is supposed

  • 0

I am building and extension with Firefox’s Addon SDK (v1.9).

My application is supposed to remove cookies as they are added (or changed) based on a database of matching URIs.

I accomplish this task by adding an observer to ‘cookie-changed’ and implementing nsICookie to identify matching cookies and nsICookieManager to remove the cookie if a match is found.

Problem

I need know what website (URL) each cookie was added / changed from.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:07:26+00:00Added an answer on June 11, 2026 at 1:07 am

    Unfortunately, by the time the cookie manager sends the cookie-changed notification that information is already lost – the cookie manager only knows which host the cookie is added for (and it might not be the host of the page setting the cookie if domain parameter was used). It might even be that there was no URL in the first place, e.g. if the cookie is set by an extension.

    What you could do is register an observer for the http-on-examine-response notification. You can look at the Set-Cookie header of the channel as well as the channel URL so when cookie-changed notification is sent later you will know which website is responsible. Something like this:

    var observer = require("observer-service");
    observer.add("http-on-examine-response", function(subject, data)
    {
      subject.QueryInterface(Ci.nsIHttpChannel);
      var cookieNames = [];
    
      // There can be more than one Set-Cookie header, cannot use getResponseHeader
      subject.visitResponseHeaders(function(header, value)
      {
        if (header.toLowerCase() == "set-cookie")
        {
          var match = /^([^\s=]+)=/.exec(value);
          if (match)
            cookieNames.push(match[1]);
        }
      });
    
      if (cookieNames.length)
      {
        var url = channel.URI.spec;
    
        // Remember that this url set the cookies or just clear the header
        if (!isAllowedToSetCookies(url, cookieNames))
          channel.setResponseHeader("Set-Cookie", "", false);
      }
    });
    

    Note: This code hasn’t been tested.

    Documentation: observer notifications, nsIHttpChannel

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an extension with Firefox's ADD ON SDK (v1.9) that will be
I am building a simple Firefox extension using the Add-on SDK 1.0. Scouring the
I am building a Firefox extension and have come a long way. One of
I am building a firefox extension. In this extension, I want to see the
I'm building a Firefox extension and would like to allow the user to delete
I'm working on a Firefox extension and started building automated tests using jsUnit. I
I am building a firefox extension and need to insert some elements and css
I am new to firefox extension building and would like some help on an
I am new to firefox extension development. I am building an extension which needs
I'm building a Firefox Extension that, among other things, needs to replace body background

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.