mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56: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();
|
||||
$started = self::started();
|
||||
|
||||
if (!self::id() && $started) {
|
||||
if (self::id() && $started) {
|
||||
self::_checkValid();
|
||||
}
|
||||
|
||||
|
@ -492,12 +492,11 @@ class CakeSession {
|
|||
* @return void
|
||||
*/
|
||||
public static function destroy() {
|
||||
$_SESSION = array();
|
||||
$_SESSION = null;
|
||||
self::$id = null;
|
||||
self::init(self::$path);
|
||||
self::start();
|
||||
self::renew();
|
||||
self::_checkValid();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,7 +111,7 @@ class CakeSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testSessionConfigIniSetting() {
|
||||
$_SESSION = array();
|
||||
$_SESSION = null;
|
||||
session_destroy();
|
||||
|
||||
Configure::write('Session', array(
|
||||
|
@ -188,6 +188,34 @@ class CakeSessionTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
@ -299,6 +327,7 @@ class CakeSessionTest extends CakeTestCase {
|
|||
$_SESSION = null;
|
||||
$this->assertFalse(TestCakeSession::started());
|
||||
$this->assertTrue(TestCakeSession::start());
|
||||
$this->assertTrue(TestCakeSession::started());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue