Craft constantly logging out from admin area While working in the Craft admin area, on a fresh install, I get logged out every once in a while. It makes the CMS unusable. 

I have tried:


Clearing cookies
Resetting the cache in the backend


Sometimes it logs out after 1 pageview, sometimes after 10. 

I am using a Macbook Pro, 10.9.3 Mavericks. This happens in both Chrome and Safari (haven't tried Firefox).

I am running Vagrant with: PHP 5.5.12, Ubunutu 14.04, Nginx. Accessing the project locally via http://project.craft.dev 

Has anyone experienced something similar? Are there any error logs for this kind of thing?

Update: in the craft.log I get a few errors:

2014/07/11 19:38:56 [trace] [system.db.CDbCommand] Querying SQL: SELECT count(`id`) FROM `craft_tasks` WHERE (level = 0) AND (status = :status). Bound with :status='error' 
in /vagrant/dlfm/craft/craft/app/etc/db/DbCommand.php (79) 
in /vagrant/dlfm/craft/craft/app/services/TasksService.php (420) 
in /vagrant/dlfm/craft/craft/app/controllers/TasksController.php (57)


and

2014/07/11 19:38:55 [error] [php] session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/vagrant/dlfm/craft/craft/storage/runtime/sessions/) (/vagrant/dlfm/craft/craft/app/services/HttpRequestService.php:852)
Stack trace:
#0 /vagrant/dlfm/craft/craft/app/framework/web/actions/CInlineAction.php(49): Craft\TasksController-&gt;actionRunPendingTasks()
#1 /vagrant/dlfm/craft/craft/app/framework/web/CController.php(308): CInlineAction-&gt;runWithParams()
#2 /vagrant/dlfm/craft/craft/app/framework/web/CController.php(286): Craft\TasksController-&gt;runAction()
#3 /vagrant/dlfm/craft/craft/app/framework/web/CController.php(265): Craft\TasksController-&gt;runActionWithFilters()
#4 /vagrant/dlfm/craft/craft/app/framework/web/CWebApplication.php(282): Craft\TasksController-&gt;run()
#5 /vagrant/dlfm/craft/craft/app/etc/web/WebApp.php(863): Craft\WebApp-&gt;runController()
#6 /vagrant/dlfm/craft/craft/app/etc/web/WebApp.php(252): Craft\WebApp-&gt;_processActionRequest()
#7 /vagrant/dlfm/craft/craft/app/framework/base/CApplication.php(180): Craft\WebApp-&gt;processRequest()
#8 /vagrant/dlfm/craft/craft/app/index.php(196): Craft\WebApp-&gt;run()
#9 /vagrant/dlfm/craft/public/index.php(14): require_once()
REQUEST_URI=/index.php/admin/actions/tasks/runPendingTasks
in /vagrant/dlfm/craft/craft/app/services/HttpRequestService.php (852)
in /vagrant/dlfm/craft/craft/app/controllers/TasksController.php (37)
in /vagrant/dlfm/craft/craft/app/etc/web/WebApp.php (863)


but this one looks most suspect:

24. 2014/07/11 19:41:47 [error] [application] Tried to restore session from a cookie, but the given login name does not match the given uid. UID: 9d515b08-1073-4872-a0e2-155c389a2991 and loginName: Jason.

24. 2014/07/11 19:41:47 [error] [application] Tried to restore session from a cookie, but the given hashed database token value does not appear to belong to the given login name. Hashed db value: 37bb858b4b13b688c4034fe5eb127f75f4931387czozNjoiNDBlNTk0YWQtNGYxZS00NjAxLWEwY2UtZDJlY2NhNDkwMmQ1Ijs= and loginName: Jason.
in /vagrant/dlfm/craft/craft/app/services/UserSessionService.php (797)
in /vagrant/dlfm/craft/craft/app/services/UserSessionService.php (64)
in /vagrant/dlfm/craft/craft/app/etc/web/WebApp.php (592)
My solution is to add:

'overridePhpSessionLocation' =&gt; false


Into craft/config/general.php

This tells Craft to use the default location to write sessions, instead of craft/storage/runtime/sessions

For whatever reason, even though  craft/storage/runtime/sessions has CHMOD 777, PHP was saving the session file with 644. When it tried to write to the same file again, it got and error and logged me out.

I also (unsuccessfully) tried giving PHP ownership of the folder, which should in theory fix the problem too.

 sudo chown -R www-data:www-data sessions
 chown: www-data: illegal group name


I am assuming it's a Vagrant/OSX thing.