diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index 4d5e71c8c..abe0823ca 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -149,7 +149,6 @@ class CakeSession { self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); } - self::_setupDatabase(); if ($start === true) { self::_setPath($base); self::_setHost(env('HTTP_HOST')); @@ -192,37 +191,6 @@ class CakeSession { } } -/** - * Setup database configuration for Session, if enabled. - * - * @return void - */ - protected function _setupDatabase() { - if (Configure::read('Session.defaults') !== 'database') { - return; - } - $modelName = Configure::read('Session.handler.model'); - $database = Configure::read('Session.handler.database'); - $table = Configure::read('Session.handler.table'); - - if (empty($database)) { - $database = 'default'; - } - $settings = array( - 'class' => 'Session', - 'alias' => 'Session', - 'table' => 'cake_sessions', - 'ds' => $database - ); - if (!empty($modelName)) { - $settings['class'] = $modelName; - } - if (!empty($table)) { - $settings['table'] = $table; - } - ClassRegistry::init($settings); - } - /** * Starts the Session. * diff --git a/cake/libs/session/database_session.php b/cake/libs/session/database_session.php index f2f7b710c..5c9d18547 100644 --- a/cake/libs/session/database_session.php +++ b/cake/libs/session/database_session.php @@ -23,6 +23,36 @@ * @package cake.libs */ class DatabaseSession implements CakeSessionHandlerInterface { + +/** + * Constructor. Looks at Session configuration information and + * sets up the session model. + * + * @return void + */ + function __construct() { + $modelName = Configure::read('Session.handler.model'); + $database = Configure::read('Session.handler.database'); + $table = Configure::read('Session.handler.table'); + + if (empty($database)) { + $database = 'default'; + } + $settings = array( + 'class' => 'Session', + 'alias' => 'Session', + 'table' => 'cake_sessions', + 'ds' => $database + ); + if (!empty($modelName)) { + $settings['class'] = $modelName; + } + if (!empty($table)) { + $settings['table'] = $table; + } + ClassRegistry::init($settings); + } + /** * Method called on open of a database session. *