Safari is losing it's cookies. Again. Or Still.

I've spent countless hours trying to debug our helpdesk software, only to finally reach the conclusion that Safari was simply losing it's cookies. Then I found a thread here, "Safari keeps logging me out..." and see that I'm hardly alone. I added to that (old) thread and it was recommended that I start the discussion again here.


The symptom is I log into the helpdesk. Some period of time later ranging from hours to days, I get an invalid login error (note that this is a web page that automatically refreshes every five minutes). Tracing the helpdesk code when this happens, I see that it has reached a point where it can find no valid authentication method, including cookies. In other words, it wasn't presented any cookies. I've debugged the helpdesk code that sets the cookies, and it only runs when it's supposed to, on initial login. The session id is still active in the helpdesk database. The software isn't unsetting these cookies.


The cookies disappear from the Show Cookies list in Preferences. They disappear from the Cookies.plist file. Other cookies which are older and expire sooner are not being deleted, so this doesn't look like some kind of house cleaning thing.


Based on the previous discussions, a lot of people seem to think this has something to do with size or number of cookies. I'm setting two cookies, which Web Inspector lists as 51 and 19 bytes respectively. There are two other active cookies for this web page, set by some other application with a more global domain name (e.g. I'm using helpdesk.foo.edu, and these cookies are for .foo.edu). The other two cookies list as 60 and 347 bytes. I'm hardly hitting any limits here. Overall there are about 30 cookies generally within the foo.edu domain, but most of these are limited to other subdomains.


One bit of weirdness here though, is that Web Inspector says "4 cookies (13.51KB)". Even in the long form storage in Cookies.plist, these four cookies only use about 2K, so maybe this is one big hint.


Here's a laundry list of other related facts:

  • The cookies in question are set to expire in one year
  • No one else here seems to be having this problem. Everyone else is on Linux.
  • Currently: Safary 5.0.5, OSX 10.6.7.
  • Problem existed on earlier versions of both Safari and OS X (but maybe only Snow Leopard?)
  • No Safari extensions installed.
  • Cookies.plist is around 4.5 MB
  • My home is an NFS home directory
  • I'm usually running next to nothing: Safari, Thunderbird, Terminal, X11
  • Cookies can get lost at any time - when I'm actively browsing elsewhere, or when I've been away from the desk for hours.
  • I don't see this anywhere else, but every other site I can think of either I use very short sessions (15 minutes, like banking or something), or I'm using session cookies (e.g. Twitter I don't ask it to remember my login).


tom

Posted on Aug 16, 2011 10:02 AM

Reply
2 replies

Aug 21, 2011 1:28 PM in response to Thomas A. Fine

So yes, just now I had some cookies vanish again. But in this case, I wasn't even using the web pages (or website) where the cookies are stored (I didn't have the auto-reloading helpdesk page open).


I left a script running which was watching my ~/Library/Cookies/Cookies.plist file, and would send me a text message if the helpdesk cookies disappeared.


I sat down at the computer which hadn't been used in a day, and reloaded a twitter page. Followed by a text message that my helpdesk cookies had disappeared. The cookies were set to expire August 18th 2012. Many of the cookies in my 4.5 MB Cookies.plist are much older cookies, set to expire much sooner than that.


So it is absolutely 100% verified that Safari is dropping cookies which are not set to expire, and are not even involved in current web activity.


tom

Nov 20, 2013 2:59 PM in response to Thomas A. Fine

This seems to be the same symptoms I see at the moment with Safari on Mavericks. It's really strange behavior that I haven't figured out why yet and by the looks of it no one has.


It appears far worse with some websites than others (gmail for example)


I've tried to "Reset Safari" from the Safari menu. Delete all passwords and cookies and even deleted safari, which meant I had to reinstall it by downloading and installing Mavericks again, becaues apple don't provide safari 7 as a separate install.


The problem has not gone away yet.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Safari is losing it's cookies. Again. Or Still.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.