Bugs & Fixes: Solving Safari Cookie Problems
A cookie is a "small piece of text stored on a user's computer by a Web browser." If you ever have a problem that appears linked to a cookie in Safari, the standard solution is to go to Safari's Preferences, select Security and click the Show Cookies button. From here, find the name of the cookie you want to delete and click to Remove it.
Unfortunately, this doesn't always solve a cookie-related problem. That's what I discovered when trying to deal with a Safari error that I've covered previously. The ironic symptom is that, when trying to load pages from Apple's Support site (especially search results), I get one of an assortment of error messages--all equally odd. The most common error is shown in the the figure below. Only the Apple site and only the Safari browser are victims of this bug!
When I last wrote about this symptom, I had not zeroed in on a solution. So I've been investigating it further. I've now found how to eradicate the symptom. But along the way, I learned some curious facts about how cookies work in Safari.
First off, the error message suggested that a cookie item named ac_history might be the proximate cause. I did find an ac_history cookie from apple.com listed in Safari's Show Cookies window (shown below). So I removed it. The errors vanished immediately, without even having to quit Safari. So far, so good. But within a short time, usually less than an hour, the symptoms returned. As did the problematic ac_history cookie. Clearly, this was not a permanent fix.
Next, I tried deleting all apple.com cookies. The result remained the same: a temporary fix at best.
Here's where things began to get a bit weird. I decided to delete all cookies. But rather than do this via Safari, with which I was rapidly losing faith, I went to ~/Library/Cookies and removed the Cookies.plist file from the folder, placing it on my Desktop.
I did this while Safari was running (which I am aware is not recommended). It had absolutely no effect. Indeed, if I returned to view the list of cookies in Safari's Preferences, it remained unchanged. All the pre-existing cookies were still listed. I figured Safari must be accessing the removed file. So I deleted it. But the cookies list in Safari did not change!
Aha! Safari must be accessing some cached copy of the data. I selected Safari -> Empty Cache. It had no effect.
Here's the final surprise: Suppose you have two different Cookies.plist files: an older one saved from some earlier troubleshooting and a new active one currently in the Cookies folder. Say the older one is stocked full of cookies and weighs in at 2.3MB, while the newer one is practically empty at only 4KB. This is exactly the situation that I had at one point in my troubleshooting of this matter. Now, still with Safari running, trash the 4KB file and drag the the larger 2.3MB file to the Cookies folder. Within a second, the 2.3MB file drops to 4KB in size, as its data are replaced with those from the deleted file! Your 2.3 MB of cookie items are gone!
It's easy to prevent this from happening. Just quit Safari before performing the swap. The next time you launch Safari, the replacement file will be active, with all its data intact. Still, it's a surprise that the vanishing act can happen it all.
Clearly, making changes to Safari's cookies can have unexpected consequences. Especially if you make changes while Safari is running. This gets me back to the ac_history bug. Rather than try to fix the bug via Safari's preferences (which I could obviously only do while Safari was running), I decided to try an alternative approach. I quit Safari and deleted its Cookies.plist file. This did permanently fix the problem at last--but at the cost of losing several MB of perfectly fine cookies.
This led to a final preferred solution: Quit Safari and launch a third-party cookie-editing utility, such as the old SafariCookieCutter utility. Delete the ac_history cookie from this utility. Or, to be extra safe, delete all apple.com cookies. When you next launch Safari, the error messages will be gone and will not return. At least that's how it worked for me.
Guest Account bug
On a completely different note, I can't end Bugs & Fixes this week without a passing mention of a widely reported but rare bug in Snow Leopard. Essentially, after logging into and logging out of a Guest account in Snow Leopard, the OS may delete all the content in your Home directory (not merely the data in the Guest account)! Needless to say, this is an unwelcome shock to victims. However, it's a very rare bug, limited to those who enabled a Guest account in Leopard and then upgraded to Snow Leopard. Even among these users, only a small minority appear affected. Apple has acknowledged the bug and indicates they will be fixing it. See the Macworld article by Rob Griffiths for more details.