Can't Delete Safari Webdata

Solution 1:

Untested - Copied from Apple Discussion thread - Safari cookies: where are they located

For macOS Sierra 10.12.6 and Safari 11.0.1, most likely, the cookies and references to websites that survive clicking -- the "Remove" and "Remove All" buttons in the Safari->Preferences->Privacy->Manage Website Data pane -- reside in each user's or account's library.

In the Utilities/Terminal.app, type
rm -frP ~/Library/Safari/Databases/* ~/Library/Safari/LocalStorage/*

That command line will terminate with extreme prejudice the files where those persistent annoyances reside.

Unix shell command line to English translation:

  1. rm is the name of the Unix command that deletes files from the filesystem.

  2. f in -frP forces rm to work quietly without complaints or asking for permission before doing anything.

  3. r in -frP instructs rm to traverse or walk the filesystem sub-tree beneath each of the pathnames that follow.

  4. P in -frP tells rm to overwrite each file or directory with junk before unlinking either a file or directory from its parent directory.

  5. The ~ (tilde) before each pathname is an abbreviation for $HOME or "my home directory."

  6. The / (slash) separates directory names in pathnames; do not replace it with any other character.

  7. The * (asterisk) after each pathname is an abbreviation for "everything that resides beyond."

Running that command line from inside an AppleScript when Safari is shut down would be ideal, but if that isn't possible, running that command from a cron file once a day would be acceptable.