Skip to content

Commit

Permalink
Removing protected var CakeSession::_started and instead session_id()…
Browse files Browse the repository at this point in the history
… is now used to check if session is started in CakeSession::started(). This fixes issue where CakeSession::started() returned incorrect value when used across multiple objects. Closes #731
  • Loading branch information
ADmad committed May 22, 2010
1 parent 06c1b58 commit 7d51952
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 3 additions & 11 deletions cake/libs/cake_session.php
Expand Up @@ -114,14 +114,6 @@ class CakeSession extends Object {
*/
var $id = null;

/**
* Session Started
*
* @var boolean
* @access protected
*/
var $_started = false;

/**
* Hostname
*
Expand Down Expand Up @@ -216,7 +208,7 @@ function start() {
session_write_close();
}
$this->__initSession();
$this->_started = $this->__startSession();
$this->__startSession();
return $this->started();
}

Expand All @@ -227,7 +219,7 @@ function start() {
* @return boolean True if session has been started.
*/
function started() {
if (isset($_SESSION) && $this->_started) {
if (isset($_SESSION) && session_id()) {
return true;
}
return false;
Expand Down Expand Up @@ -795,5 +787,5 @@ function __gc($expires = null) {

$return = $model->deleteAll(array($model->alias . ".expires <" => $expires), false, false);
return $return;
}
}
}
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/cake_session.test.php
Expand Up @@ -170,6 +170,10 @@ function testStarted() {
$_SESSION = null;
$this->assertFalse($this->Session->started());
$this->assertTrue($this->Session->start());

$session = new CakeSession(null, false);
$this->assertTrue($session->started());
unset($session);
}

/**
Expand Down

0 comments on commit 7d51952

Please sign in to comment.