Just like Chrome, Mac's browser Safari doesn't support the automatic deletion of browsing cookies when you quit the browser. Is there any browser extension or any other method to delete cookies automatically?
-
What is the reason for the down-vote? – gloschtla Sep 20 '20 at 09:46
-
I posted this question here on stackoverflow, because the same question on stackexchange for apple was not found by stackexchange's meta search query. Anyway, I reposted the answere there as well: https://apple.stackexchange.com/a/401635/342575 – gloschtla Sep 20 '20 at 09:52
1 Answers
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
a) Open Safari b) Go to Preferences –> Security - > Show Cookies c) Delete all Cookies d) Quit Safari without loading any website in between e) Open Finder f) Go to „/Users/XXXXXX/Library/Cookies/“ (Replace XXXXX with your username) g) 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
a) Open Terminal b) Type: „cd /Library/StartupItems/“ c) Type: „sudo mkdir /DeleteCookies“ - > Enter your password d) Type: „sudo pico“ (a shell text editor will open) e) Paste this inside:
{quote}
#!/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"
{quote}
f) Change „XXXXX“ to your username (at two places!) g) Press „Ctrl - X“ (it asks if it should save the document) h) Press „Y“ (it asks for a file name) i) Type „DeleteCookies“ j) Don’t close the Terminal! We will need it again.
3. Create StartupParameters
a) In Terminal type: „sudo pico“ b) Paste this inside (with { and }):
{quote}
{
Description = "DeleteCookies";
Provides = ("Deletes Safari cookies on shut down");
Uses = ("Disks");
}
{quote}
c) Press „Ctrl - X“ (it asks if it should save the document) d) Press „Y“ (it asks for a file name) e) Type „StartupParameters.plist“ f) 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
a) Restart your computer b) After reboot it will tell you that StartupItems do not have the right permissions c) Click on „Correct Permissions“ (2 times for the two created files) d) Restart your computer again.
Now your Safari-Cookies should be deleted automatically each time when you shut down your PC.
Text source: apple community

- 41
- 3
- 10