Safari does not provide an option to auto-delete cookies on quit as other browsers do. So the idea is, to delete the cookies on shut down of Mac OS X using a shell script:
1. Create an empty Cookie file
- Open Safari
- Go to Preferences –> Security - > Show Cookies
- Delete all Cookies
- Quit Safari without loading any website in between
- Open Finder
- Go to „/Users/XXXXXX/Library/Cookies/“ (Replace XXXXX with your username)
- Copy „Cookies.plist“ to „CleanedCookies.plist“ in this folder*
Done! Now you should see two files in the folder „~/Library/Cookies/“: „Cookies.plist“ and „CleanedCookies.plist“!
2. Create autostart shell script
Open Terminal
Type: „cd /Library/StartupItems/“
Type: „sudo mkdir /DeleteCookies“ - > Enter your password
Type: „sudo pico“ (a shell text editor will open)
Paste this inside:*
#!/bin/sh
. /etc/rc.common
#StartService ()
#{
#}
StopService ()
{
cp -f /Users/XXXXX/Library/Cookies/CleanedCookies.plist /Users/XXXXX/Library/Cookies/Cookies.plist
}
RestartService ()
{
StopService
}
RunService "$1"
Change „XXXXX“ to your username (at two places!)
Press „Ctrl - X“ (it asks if it should save the document)
Press „Y“ (it asks for a file name)
Type „DeleteCookies“
Don’t close the Terminal! We will need it again.*
3. Create StartupParameters
In Terminal type: „sudo pico“
Paste this inside (with { and }):*
{quote}
{
Description = "DeleteCookies";
Provides = ("Deletes Safari cookies on shut down");
Uses = ("Disks");
}
{quote}
Press „Ctrl - X“ (it asks if it should save the document)
Press „Y“ (it asks for a file name)
Type „StartupParameters.plist“
Now you may close the Terminal*
Now you should see two files in the folder „/Library/StartupItems/DeleteCookies/“: „DeleteCookies“ and „StartupParameters.plist“. Done!
4. Restart the system
- Restart your computer
- After reboot it will tell you that StartupItems do not have the right permissions
- Click on „Correct Permissions“ (2 times for the two created files)
- Restart your computer again.*
Now your Safari-Cookies should be deleted automatically each time when you shut down your PC.
Text source: apple community