I keep on getting logged out whenever I deploy using Capistrano, despite the sessions being stored persistently (in the craft/storage folder).
The problem is that the basepath changes each time you deploy (Capistrano uses versioned release directories). The basepath is used to generate a session key, which is invalidated each time a new deployment is made.
The answer is to add the
appId parameter to
config/general.php. The docs give a good explanation
The application ID, which is used for things like storing data caches and user sessions. If it’s not set, Craft will automatically generate one based on the server path. Setting it will help avoid the loss of data caches and user sessions when Craft is deployed using a deployment script that will store Craft in an inconsistent location, such as Capistrano.
So add this to
'appId' => 'chooseyourownrandomstring',