Delete all cookies except those from certain sites with Firefox

 Mon, 13 May 2024 10:16 UTC

Delete all cookies except those from certain sites with Firefox
Image: CC BY 4.0 by cybrkyd


What I love most about Firefox is the ability to wipe all history, cookies and site data on exit. Firefox was among the first to implement this feature. It stops the annoying tracking cookies following you around as you browse. The only drawback is that it will also kill all session cookies, which means that any active logins will be terminated.

This guide explains how to configure your Firefox browser to automatically delete some but not all cookies and other browsing data whenever you close it. You’ll learn how to retain cookies from your custom list of whitelisted sites — useful for staying logged in on specific websites like google.com or twitter.com.

Delete cookies and create a whitelist

  1. Open a new tab and type in: about:preferences#privacy and press enter.
  2. Locate the Cookies and Site Data section.
  3. Tick the box next to “Delete cookies and site data when Firefox is closed”. Your preferences should now look like this:

Delete cookies and site data when Firefox is closed

Next, to create a whitelist,

  1. Click on the Manage Exceptions… button.
  2. In the pop-up window, add the whitelisted site to the “Address of web site” field and then press “Allow”.

Firefox cookies exceptions

The site address will then appear in the bottom section with the status “Allow”, indicating that it has been whitelisted. Repeat the above process to add more web sites you want to whitelist. When complete, click on “Save Changes” to close the pop-up window.

Delete History

  1. Scroll down on the preferences page about:preferences#privacy and locate the History section.
  2. From the History drop-down menu, select “Use custom settings for history”.
  3. Ensure “Clear history when Firefox closes” is selected. The other settings can be un-ticked. Your preferences should now look like this:

History

  1. Next, whilst still in the History section, click on the Settings… button. In the pop-up window that appears, tick all options, but un-tick “Active logins”.

Settings

I have also opted to retain “Site settings” so have left this one un-ticked. This is used for site-specific preferences which include the saved zoom level for sites, character encoding, and other permissions like pop-up blocker exceptions, autoplay, etc.

  1. Click OK once you have finished and then close the pop-up window.

You have just enabled a form of permanent private browsing privacy in Firefox which will automatically delete all history, cookies and site data except the cookies, data and settings for your whitelisted web sites. Test it by browsing to some websites, then close and reopen Firefox and check what remains.