Merge pull request #4405 from php-engineer/master-session-bugfix

CakeSession::delete() bugfix
This commit is contained in:
Mark Story 2014-08-26 12:43:02 -04:00
commit 5863adda42
2 changed files with 7 additions and 1 deletions

View file

@ -267,7 +267,7 @@ class CakeSession {
* @return bool Success
*/
public static function delete($name) {
if (self::check($name)) {
if (self::start() && self::check($name)) {
self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
return !self::check($name);
}

View file

@ -365,6 +365,12 @@ class CakeSessionTest extends CakeTestCase {
* @return void
*/
public function testDelete() {
$this->assertTrue(TestCakeSession::write('Delete.me', 'Clearing out'));
session_write_close();
$this->assertTrue(TestCakeSession::delete('Delete.me'));
$this->assertFalse(TestCakeSession::check('Delete.me'));
$this->assertTrue(TestCakeSession::write('Delete.me', 'Clearing out'));
$this->assertTrue(TestCakeSession::delete('Delete.me'));
$this->assertFalse(TestCakeSession::check('Delete.me'));