application/Bootstrap.php: Store session data in database
This commit is contained in:
parent
b3b099444a
commit
b4a69dc6bf
1 changed files with 32 additions and 2 deletions
|
|
@ -245,7 +245,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
* Setup a sweet and simple database
|
||||
* connection.
|
||||
*
|
||||
* @return Zend_Db $database
|
||||
* @return Zend_Db
|
||||
*/
|
||||
protected function _initDatabase()
|
||||
{
|
||||
|
|
@ -253,7 +253,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
$config = $this->getApplication()->getOptions();
|
||||
|
||||
// Setup database adapter
|
||||
$database = Zend_Db::factory('Pdo_Mysql', $config['db']);
|
||||
$database = Zend_Db::factory($config['db']['adapter'], $config['db']);
|
||||
|
||||
// Use the adapter by default
|
||||
Zend_Db_Table::setDefaultAdapter($database);
|
||||
|
|
@ -261,6 +261,20 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
return $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup auth
|
||||
*
|
||||
* @return Zend_Auth
|
||||
*/
|
||||
protected function _initAuth()
|
||||
{
|
||||
$this->bootstrap('session');
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
return $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup session
|
||||
*
|
||||
|
|
@ -268,6 +282,22 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
*/
|
||||
protected function _initSession()
|
||||
{
|
||||
$this->bootstrap('database');
|
||||
|
||||
// Setup session storage in database
|
||||
$options = array(
|
||||
'name' => 'Session',
|
||||
'primary' => 'sid',
|
||||
'modifiedColumn' => 'mtime',
|
||||
'lifetimeColumn' => 'ltime',
|
||||
'dataColumn' => 'data'
|
||||
);
|
||||
|
||||
$handler = new Zend_Session_SaveHandler_DbTable($options);
|
||||
|
||||
Zend_Session::setSaveHandler($handler);
|
||||
|
||||
// Now, start session.
|
||||
Zend_Session::start();
|
||||
|
||||
// TODO: Better name for global session namespace (default namespace)
|
||||
|
|
|
|||
Reference in a new issue