mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Changing clear of $_SESSION to null instead of array(), makes checks later easier. Removing _checkValid call from destroy and making it run in start(), as destroy() calls start().
This commit is contained in:
parent
a857e4505c
commit
574bfe6b67
2 changed files with 32 additions and 4 deletions
|
@ -239,7 +239,7 @@ class CakeSession {
|
||||||
self::_startSession();
|
self::_startSession();
|
||||||
$started = self::started();
|
$started = self::started();
|
||||||
|
|
||||||
if (!self::id() && $started) {
|
if (self::id() && $started) {
|
||||||
self::_checkValid();
|
self::_checkValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,12 +492,11 @@ class CakeSession {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function destroy() {
|
public static function destroy() {
|
||||||
$_SESSION = array();
|
$_SESSION = null;
|
||||||
self::$id = null;
|
self::$id = null;
|
||||||
self::init(self::$path);
|
self::init(self::$path);
|
||||||
self::start();
|
self::start();
|
||||||
self::renew();
|
self::renew();
|
||||||
self::_checkValid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,7 +111,7 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSessionConfigIniSetting() {
|
function testSessionConfigIniSetting() {
|
||||||
$_SESSION = array();
|
$_SESSION = null;
|
||||||
session_destroy();
|
session_destroy();
|
||||||
|
|
||||||
Configure::write('Session', array(
|
Configure::write('Session', array(
|
||||||
|
@ -188,6 +188,34 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
$this->assertEqual('cakephp.org', TestCakeSession::$host);
|
$this->assertEqual('cakephp.org', TestCakeSession::$host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test valid with bogus user agent.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testValidBogusUserAgent() {
|
||||||
|
Configure::write('Session.checkAgent', true);
|
||||||
|
TestCakeSession::start();
|
||||||
|
$this->assertTrue(TestCakeSession::valid(), 'Newly started session should be valid');
|
||||||
|
|
||||||
|
TestCakeSession::userAgent('bogus!');
|
||||||
|
$this->assertFalse(TestCakeSession::valid(), 'user agent mismatch should fail.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test valid with bogus user agent.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testValidTimeExpiry() {
|
||||||
|
Configure::write('Session.checkAgent', true);
|
||||||
|
TestCakeSession::start();
|
||||||
|
$this->assertTrue(TestCakeSession::valid(), 'Newly started session should be valid');
|
||||||
|
|
||||||
|
TestCakeSession::$time = strtotime('next year');
|
||||||
|
$this->assertFalse(TestCakeSession::valid(), 'time should cause failure.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testCheck method
|
* testCheck method
|
||||||
*
|
*
|
||||||
|
@ -299,6 +327,7 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
$_SESSION = null;
|
$_SESSION = null;
|
||||||
$this->assertFalse(TestCakeSession::started());
|
$this->assertFalse(TestCakeSession::started());
|
||||||
$this->assertTrue(TestCakeSession::start());
|
$this->assertTrue(TestCakeSession::start());
|
||||||
|
$this->assertTrue(TestCakeSession::started());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue