Safari Cookies


Safari now uses a completely different method of storing cookies, which unfortunately means that the only decent management tool I ever found, Cocoa Cookies, doesn’t work any more.

So I rolled my own:

(/usr/libexec/PlistBuddy -c print
~/Library/Cookies/Cookies.plist |
awk '/Domain = / {x++;print x-1,$0}' |
awk '!/mee.nu|amazon/{print $1}' |
sort -rn | sed -e 's/^/delete :/';
echo save;echo quit) |
/usr/libexec/PlistBuddy
~/Library/Cookies/Cookies.plist

Note that you really don’t want to run this as-is, and probably want something more robust than a shell one-liner anyway. The bits that matter are:

  1. run "/usr/libexec/PlistBuddy -c print" to dump all your cookies in an easily-parsed format.
  2. The array of cookies is zero-based.
  3. The array shrinks as you delete things from it with "delete :N", so you want to start at the end and work forward.
  4. The original file isn't altered until you send a "save".
  5. Safari seems to write this file out whenever you get a cookie, and notices when it's changed on disk.