AppFog:每次更新应用程序时,所有用户都会自动注销

Each time when I update my application on AppFog then all logged in users are logging out automatically.

Because of session lost!

How can I solve this problem?

The application has built in PHP on top of Yii Framework 1.1.14

It may be either due to session or due to authorisation file being overwritten during an update..

refer: http://www.yiiframework.com/doc/api/1.1/CHttpSession#savePath-detail and http://in2.php.net/manual/en/session.configuration.php#ini.session.save-path

The authorisation temp file is stored in /protected/data/auth.php by default.

You can avoid this by either specifying a different path to those files, the session file defaults to php session save path, or moving the session management to the DB. Using CDbHttpSession instead of CHttpSession and CDbAuthManager instead of CPhpAuthManager respectively, this article explains session management in yii in more detail.

It is more likely an authorisation issue as the application, directory get overwritten during an update rather than system tmp directories. If you use version control to update your app you can configure it to ignore this file (.gitignore or equivalent).

The AppFof filesystem is not persistent. When you update you are rebuilding the application to essentially a new server so anything stored in the filesystem is lost, including the session files.

Probably the only solution is to save the session details to a database.

The problem is, that Yii uses CApplication::getId() to generate cookie ID. This method uses basePath to generate that ID.

return $this->_id=sprintf('%x',crc32($this->getBasePath().$this->name));

As you deploy new version, the base path of your application changes, so cookie ID is regenerated and sessions are lost.

The solution would be to specify your own application ID in protected/config/main.php

"id" => md5(php_uname().'somHardGuessableRandomString'),

somHardGuessableRandomString part should be randomly generated.