- Store all cookies as normal
- Maintain a whitelist of servers that are allowed to store persistent cookies (usually for sites such as Github, Reddit, Twitter and the like)
- At regular intervals (preferably every time the browser is closed), delete all cookies not whitelisted.
Thus as an experiment I wrote a Python script to do this, it is available in this Github repo. Using it is simple:
- Write a whitelist file consisting of one hostname per line. (all subdomains of the specified host are also permitted)
- Shut down Firefox.
- Run the script.
- Start Firefox.