I have found this solution, had this problem before upgrading to 10.9 on both my macbook pro and imac. After the update didn't have the problem on macbook pro however it presisted on the imac. I did the following and worked so far:
Safari => Preferences => Passwords => Remove All
Safari => Preferences => Privacy => Remove All Website Dara
Hope it works!
I've been experiencing this for a couple of days now as well. I'm getting logged out of everything basically after a few minutes.
I've tried deleting all website data, passwords and all application data I can find, but I'm still experiencing the problem.
It's starting to sound like a session cookie problem like someone mentioned before. I'm wondering if I should just remove safari and try to reinstall it..
(I'm on OSX Mavericks and Safari 7)
I've found a solution! Don't use Safari, or any other Apple software. Although it may look nice, they rarely work correctly. Safari, Pages, Keynote, Numbers - none of them work correctly on my 2012 iMac or 2012 MacBook Pro. It's a shame because up until this year I never experienced any problems with my Apple products. Unfortunately, I think they're just starting to lose their way.
Something that oddly worked for me was that I posted to my Twitter account via Notification Centre. As soon as I did that, Twitter began allowing me to stay logged in for more than 10 seconds. Not sure if it's a perminant fix, but worth a try.
OK... so 3rd time lucky. This is how I fixed this problem on OSX Mavericks and Safari 7.
My problem was a cookie problem. Something was corrupted with how safari was keeping cookies.
I would have thought that "Reset Safari..." from the Safari menu, or going into preferences-> privacy and "delete all website data" would have fixed my logging out problem but it didn't.
I finally discovered that Safari cookies are stored in these locations:
I quit safari and then deleted all the filed in the above directories, and now finally safari seems to be behaving itself normally and I've been looged into all websites for a couple of hours now without being logged out.
I've deleted even more Safari related files, but still getting the logout problem.
Here's a list of files I deleted:
~/Library/Saved Application State/com.apple.Safari.savedState
I noticed this problem since Safari 7.0.x (maybe 7.0.3, can't remember the exact version), and tried reset and delete related files with every Safari update.
Now it's Safari 8 on Yosemite, the problem still exists.
I also had this problem, every 5 minutes sometimes less with no activity, Safari log me out of Facebook, so I already fixed, HOW? well, I go to my Facebook settings, then applications, and REMOVE Skype app.
I don't know why, Chrome works excellent with Skype app but no Safari, so just delete Skype App from Facebook apps.
Hope it works for you
I have an Macbook Pro Retina Display with OS X Yosemite with the last update.