Is there a way to tell Firefox to only keep persistent cookies from sites I want? I don't mind "session cookies" from all sites, but persistent cookies, I only want from a handful of sites to "keep me logged in".
You can pick and choose which sites you want to keep cookies from or want to block from ever getting.
Tools > Options > Privacy
The Options dialog will appear. This is where you set your cookies preferences.
To allow cookies to be set in the first place, check the following box:
☑ Accept cookies from sites
To keep all cookies from sticking, essentially turning them into session cookies (ones that won't be there next time you restart Firefox), select the option that will destroy them when you exit the browser:
Keep until: I close Firefox
To allow persistent cookies, ones that will be there next time Firefox is started, click Exceptions...
Type in the domain of the site(s) you want to always accept and keep cookies from. Click Allow for each.
If instead you would like to prevent certain sites from ever storing cookies, click Block.
When you've finished entering all the sites, click Close, then OK and you're done.
The CookieSafe allows you do this easily from the status bar. Set it to 'Deny Cookies Globally', then allow the sites you want.
After setting the default behavior to deny cookies as explained in other answers, I use Cookie Button in the Status Bar extension.
It's one of the more comfortable ways to control cookies permission with a single click and yet it's very unobtrusive.
The selected answer still works in 2017, looks a bit different.
You can do this (see screenshots of Firefox Options) Clear cookies when closing Firefox screenshot 1
You can whitelist your trusted sites using Exceptions Whitelist trusted sites screenshot 2
If you want to sync these settings across Firefox on different devices you can use a Firefox account (I can't add the 3rd link as I'm newbie on this site).
More details here Mozilla support of actions to take if Firefox is not clearing your cookies as expected.
Tools - Options - Privacy - Choose custom policy change your setting how you want them, you can add exceptions for sites you want or don't want. The flexibility is quite powerful.
There are a number of cookie plugins that allow you to do this. I use one at home (forget the name) and have my default set to "deny", only allowing cookies on sites I like.
Cookie Culler is another way to have unwanted cookies deleted when you close Firefox.