MacOS – Safari loses web site “login” state after computer restarts

cookiesmacosrebootsafari

I have a problem with Safari losing my web site login state after a computer restart. For example, if I am logged in to Facebook or StackExchange the before a restart, then after the restart I will be prompted to log in to the site again.

Simply restarting Safari doesn't cause the problem nor does logging out and logging back in – It only occurs on an OS X restart.

The other interesting thing is that if I log in and start Safari immediately after the machine restart then my web sessions are still active but after about 30 seconds I will be logged out of the site.

For example, if Safari automatically restores the tab with Facebook I will see my Facebook feed and then after about 30 seconds a pop up comes up asking me to log in to Facebook.

This only seems to affect my user account and only on this one computer and it seems to affect any site with a log in, but not "insecure" cookies. It also doesn't affect the usernames/passwords stored in the Keychain.

I am running OS X 10.10.5 and Safari 8.0.8.

Update

I should have said I have already tried deleting

~Library/Safari
~Library/Caches/com.apple.Safari
~Library/Caches/com.apple.Safari.SearchHelper
~Library/Caches/com.apple.SafariServices

and, as suggested by @TonyWilliams

~Library/Cookies/Cookies.binarycookies
~/Library/Cookies/com.apple.Safari.SafeBrowsing.binarycookies

Best Answer

I seem to have resolved this problem by unchecking the "Reopen windows when logging back in" box on the restart dialog. Once I did that I was able to log back in and then run Safari without it losing my site logins.

Interestingly I was then able to re-enable that checkbox and restart again without issue, so it seems that something in the restore process was borked.