Skip to content

Keep Allowed Site Cookies When Firefox Closes

Firefox may clear cookies for sites you have allowed when the browser closes if its automatic clearing settings override your per-site exception.

To keep a site's cookies, turn off Firefox's delete-on-close option, confirm the History setting uses custom settings, and check the site's exact sign-in address.

In this guide, I have covered:

Stop Firefox from deleting allowed cookies on close

Firefox’s automatic cookie clearing can override a site’s exception when you close the browser. Turn off the option that deletes cookies and site data when Firefox closes.

  1. Click the hamburger menu horizontal 3-bar icon at the top right of Firefox and choose Settings.
  2. Select Privacy & Security from the left sidebar.
  3. Under History, change Firefox will to Remember history if it is not already selected.
  4. If you use custom settings, untick Clear history when Firefox closes.
  5. Click Settings… next to it and untick Cookies in the popup list.
  6. Restart Firefox once for the change to take effect.

After changing the setting, sign in to the affected site again, close Firefox completely, reopen it, and check whether you remain signed in.

Check the History clearing setting

Firefox links the cookie option to its History controls. If History is set to clear cookies and site data on close, the global setting can override the exception you made for one site.

  1. Open Firefox Settings and select Privacy & Security.
  2. Scroll to History and open the clearing settings.
  3. Select Use custom settings if it is available.
  4. Clear history when Firefox closes only if you want that behavior.
  5. Review the selected items so cookies and site data are not removed on every exit.

Return to Privacy & Security → Cookies and Site Data and confirm that Delete cookies and site data when Firefox is closed is unchecked. The two settings are linked, so changing one can change the other.

For a related setting, see Clear Browser Cookies and Cache from the Mozilla Firefox.

Confirm the site’s exception

A per-site exception must match the address that handles the site’s sign-in. An exception for one address may not cover a separate sign-in or account domain.

  1. Click horizontal 3-bar icon menu in the top-right of Firefox and choose Settings.
  2. Select Privacy & Security from the left sidebar.
  3. In the Cookies and Site Data section, click the Manage Exceptions… button.
  4. Type the full site address (for example, https://example.com) in the Address of website field.
  5. Set the Status dropdown to Allow for Session (not plain Allow).
  6. Click Save Changes, then close the dialog.
  7. Reload the site in the browser.

In the exceptions manager, check that the entry covers the exact address you use to sign in. If the site redirects you to a different domain, add an exception for that domain too.

Test the site in a private window

A private window shows how the site behaves when no stored session data is available. Use it only to find out whether cookies are the cause. It won’t keep your normal browsing session.

  1. Press Ctrl + Shift + P (or Cmd + Shift + P on macOS) to open a Private Window.
  2. Visit the site that was not accepting cookies.
  3. If it works here, return to the normal window and run Troubleshoot Mode to disable extensions temporarily.

Handle a separate sign-in domain

Some services send you to a different domain to sign in. If the main site is allowed but the login happens on a subdomain, the exception may not cover the session cookie that Firefox removes on close.

  1. Note the address shown in the address bar when the site asks you to sign in.
  2. Open Firefox Settings → Privacy & Security → Cookies and Site Data.
  3. Open the exceptions manager and check that the sign-in domain is listed with storage allowed.
  4. Close Firefox completely, reopen it, and test the session again.

A site can also end a session because of its own session lifetime. If the exception and clearing settings are correct but the site still signs you out, check the site’s session or login settings.

More Firefox cookie settings

Mozilla’s guide to cookies and site data explains what the two contain.

Frequently Asked Questions

How do I keep one site signed in while clearing other cookies on close?

Use Firefox’s custom clearing settings and make sure the site’s exact address is listed in the exceptions manager. If the site signs in through a separate domain, add that domain as well.

Does clearing history on close always delete cookies?

It depends on the items selected in Firefox’s custom History clearing settings. Review the selection and remove cookies and site data from it if you want to keep them.

Why does Firefox sign me out even after I allow the site’s cookies?

The site may use a separate sign-in domain or enforce its own session lifetime. Check the address used during login, then confirm each relevant domain has an exception.

Will a private window preserve my Firefox session?

No. A private window is meant for temporary browsing and does not keep your regular Firefox profile’s session. Use it as a test, then adjust the regular profile’s cookie settings.

Please share the article if you find it helpful:

Disclosure: This page may contain affiliate links, which means we may receive compensation for your purchases; of course at no extra cost to you (indeed, you may get special discounts).
Jack Mitchell

Jack Mitchell

Jack Mitchell is a software engineering graduate. He moved to Firefox for container tabs and privacy controls, so most Chrome extensions are gone. He surfs when the swell is good and keeps chillies alive on the balcony.

Leave a thought or feedback

Please leave a descriptive comment or feedback with your real name. Our human moderator vets every comment, and it may take 24 to 48 hours to get published or rejected.
Your email address will not be published, and we will never spam your inbox. Required fields are marked *