If you visit the Google homepage in any web browser, the search giant will leave behind a cookie that lasts for 20 years. Every website you randomly visit one can do the same. Do you need to store long-lasting cookies for all the websites you’ve only visited once? With Firefox, you don’t have to.
Update (): The features and settings described in this article have been retired and no longer works as of Firefox 63.
Manually clearing cookies in your browser is inconvenient. However, you can still have a lean cookiejar in your web browser by reducing how long cookies can remain in your browser.
Some website may reset their cookies every time you visit them, while others will set it once and wait for it to expire. When your cookies expire, you may need to login to services anew or set some site preferences again. Dropping cookies can for some websites lead to a decreased user experience, but may yield an overall net gain in performance and possibly also privacy.
- Type about:config in the address field and press Enter
- Take the warning to heart, and proceed
- Search for network.cookie.lifetime in the list of options.
- Change the value of network.cookie.lifetimePolicy to 3.
This change will reduce the maximum lifetime of new cookies to three months (90 days) by default. After 90 days, cookies will be deleted from your web browser automatically. Existing cookies will not be readjusted, but if you delete all cookies once then the change will apply to all cookies.
You can configure the number of days to store cookies by changing the network.cookie.lifetime.days option to the number of days you want your browser to be storing cookies.
You should set this value lower the more time you spend in your web browser, and the more likely you are to browse through many new and different websites per day. I’ve reduced the default from three months to three weeks (21 days).
This works on both Firefox for desktop, and Firefox Mobile for Android. The setting will be synchronized between the your devices with Firefox Sync unless you disable the services.sync.prefs.sync.network.cookie.lifetimePolicy and services.sync.prefs.sync.network.cookie.lifetime.days options.
The options mentioned in this article are unavailable in Firefox for iOS (which uses WebKit instead of Mozilla Gecko), and Firefox Focus for Android and iOS (which deletes all cookies on exit).
As a fun factoid at the end: If you look around in your web browser’s cookie storage (the “cookiejar”), you’ll undoubtedly notice that an uncanny amount of cookies will expire in the beginning of the year 2038. This is because of the Year 2038 Problem: One common way of storing timepoints is as the number of seconds from the epoch, the 1st of January 1970. When using 32-bit numbers, the latest possible value is early in 2038. If you try to go past that point, the counter wraps around and starts at zero (that is, 1970) again, producing dates in the past.