Periodically deleting cookies in Safari

It seems as though extensions in Safari can't access cookies. In firefox there is a great add-on that immediately deletes cookies from a site after you close its tab. This is really helpful for viewing sites that require cookies, but that you don't want following you all over the internet.

Is there any approach I could take to mimic this behavior in Safari? I was thinking some sort of watcher on the cookie folder or linking it to /dev/null/, but I'd still like to whitelist some cookies that I don't mind keeping around and I wouldn't want to add much cpu or battery usage either.


Solution 1:

If you open Safari in private browsing mode, all cookies you may have are not accessible. Feel free to log in to whatever site you want and the cookies only persist for that session as you are familiar with from Firefox.

If you want to script a periodic purging of all cookies, that is trivial if you use Automator to record the action of launching safari, selecting preferences and selecting the clear all cookies button.

That's probably overkill, since private browsing does about all you ask already.

Solution 2:

  1. There exists a paid app for that on the Mac App Store: https://itunes.apple.com/us/app/cookie-5/id1048338802

    It covers periodic and on-exit clearing of cookies as well.

    [No affiliation, I'm just a user.]

  2. There is also an open source solution to manage cookies, though it's not maintained anymore and — according the README notice — it doesn't support El Capitan: https://github.com/nickzman/safaricookiecutter