Skip to content

Commit 7d51952

Browse files
committed
Removing protected var CakeSession::_started and instead session_id() 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
1 parent 06c1b58 commit 7d51952

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

cake/libs/cake_session.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ class CakeSession extends Object {
114114
*/
115115
var $id = null;
116116

117-
/**
118-
* Session Started
119-
*
120-
* @var boolean
121-
* @access protected
122-
*/
123-
var $_started = false;
124-
125117
/**
126118
* Hostname
127119
*
@@ -216,7 +208,7 @@ function start() {
216208
session_write_close();
217209
}
218210
$this->__initSession();
219-
$this->_started = $this->__startSession();
211+
$this->__startSession();
220212
return $this->started();
221213
}
222214

@@ -227,7 +219,7 @@ function start() {
227219
* @return boolean True if session has been started.
228220
*/
229221
function started() {
230-
if (isset($_SESSION) && $this->_started) {
222+
if (isset($_SESSION) && session_id()) {
231223
return true;
232224
}
233225
return false;
@@ -795,5 +787,5 @@ function __gc($expires = null) {
795787

796788
$return = $model->deleteAll(array($model->alias . ".expires <" => $expires), false, false);
797789
return $return;
798-
}
790+
}
799791
}

cake/tests/cases/libs/cake_session.test.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ function testStarted() {
170170
$_SESSION = null;
171171
$this->assertFalse($this->Session->started());
172172
$this->assertTrue($this->Session->start());
173+
174+
$session = new CakeSession(null, false);
175+
$this->assertTrue($session->started());
176+
unset($session);
173177
}
174178

175179
/**

0 commit comments

Comments
 (0)