How to remove https cookie?

Hello, I’m trying to remove https cookie using WebExtension API, but promise is always fulfilled with null. The code works fine for normal http cookies. Is there anything i’m missing?

The following is fulfilled with null:
var removing = browser.cookies.remove({url: ‘https://example.com’, name: cookie.name, storeId: cookie.storeId});
removing.then(onCookieRemoved, onCookieRemovalError).catch(onCookieDeletionError);

And this works fine:
var removing = browser.cookies.remove({url: ‘http://example.com’, name: cookie.name, storeId: cookie.storeId});
removing.then(onCookieRemoved, onCookieRemovalError).catch(onCookieDeletionError);

I tested this and it works for me:

  • Make sure to specify the correct host match patterns in your manifest. If you want mozilla.org for both http and https, use *://mozilla.org/ or ://mozilla.org/ to include subdomains. There’s also <all_urls> which includes both http and https.

  • You specify a storeId in browser.cookie.remove(). Are you sure you don’t want that to be null?

Let me know if you want my sample code.

1 Like

@ericjung1, thank you very much, your answer is right. After having a deeper investigation it turns out that my problem was in cookie.path. This needs to be appended to URL for cookie to be removed.