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:
rm is the name of the Unix command that deletes files from the filesystem.
f in -frP forces rm to work quietly without complaints or asking for permission before doing anything.
r in -frP instructs rm to traverse or walk the filesystem sub-tree beneath each of the pathnames that follow.
P in -frP tells rm to overwrite each file or directory with junk before unlinking either a file or directory from its parent directory.
The ~ (tilde) before each pathname is an abbreviation for $HOME or "my home directory."
The / (slash) separates directory names in pathnames; do not replace it with any other character.
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.