Rename constructor to init() and add init() call at bottom of CakeSession.

This commit is contained in:
predominant 2010-07-04 20:06:24 +10:00 committed by mark_story
parent 3430930fde
commit b0e4a09d38

View file

@ -32,7 +32,7 @@
* @package cake * @package cake
* @subpackage cake.cake.libs * @subpackage cake.cake.libs
*/ */
class CakeSession extends Object { class CakeSession {
/** /**
* True if the Session is still valid * True if the Session is still valid
@ -139,15 +139,16 @@ class CakeSession extends Object {
* @param string $base The base path for the Session * @param string $base The base path for the Session
* @param boolean $start Should session be started right now * @param boolean $start Should session be started right now
*/ */
public function __construct($base = null, $start = true) { public static function init($base = null, $start = true) {
App::import('Core', array('Set', 'Security')); App::import('Core', array('Set', 'Security'));
self::$time = time(); self::$time = time();
if (Configure::read('Session.checkAgent') === true || Configure::read('Session.checkAgent') === null) { $checkAgent = Configure::read('Session.checkAgent');
if (env('HTTP_USER_AGENT') != null) { if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT') != null) {
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
} }
} unset($checkAgent);
if (Configure::read('Session.save') === 'database') { if (Configure::read('Session.save') === 'database') {
$modelName = Configure::read('Session.model'); $modelName = Configure::read('Session.model');
$database = Configure::read('Session.database'); $database = Configure::read('Session.database');
@ -187,13 +188,9 @@ class CakeSession extends Object {
} }
} }
if (isset($_SESSION) || $start === true) { if (isset($_SESSION) || $start === true) {
if (!class_exists('Security')) {
App::import('Core', 'Security');
}
self::$sessionTime = self::$time + (Security::inactiveMins() * Configure::read('Session.timeout')); self::$sessionTime = self::$time + (Security::inactiveMins() * Configure::read('Session.timeout'));
self::$security = Configure::read('Security.level'); self::$security = Configure::read('Security.level');
} }
parent::__construct();
} }
/** /**
@ -757,3 +754,6 @@ class CakeSession extends Object {
return $return; return $return;
} }
} }
// Initialize the session
CakeSession::init();