Skip to content

Commit cc4d849

Browse files
authored
Merge pull request SAML-Toolkits#412 from SwenVanZanten/master
Empty instead of unset the $_SESSION variable
2 parents a4619e0 + 1d2c226 commit cc4d849

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/Saml2/Utils.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,12 +966,11 @@ public static function isSessionStarted()
966966
*/
967967
public static function deleteLocalSession()
968968
{
969+
session_unset();
969970

970971
if (OneLogin_Saml2_Utils::isSessionStarted()) {
971972
session_destroy();
972973
}
973-
974-
unset($_SESSION);
975974
}
976975

977976
/**

tests/src/OneLogin/Saml2/UtilsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ public function testGetselfhost()
370370
public function testisHTTPS()
371371
{
372372
$this->assertFalse(OneLogin_Saml2_Utils::isHTTPS());
373-
373+
374374
$_SERVER['HTTPS'] = 'on';
375375
$this->assertTrue(OneLogin_Saml2_Utils::isHTTPS());
376-
376+
377377
unset($_SERVER['HTTPS']);
378378
$this->assertFalse(OneLogin_Saml2_Utils::isHTTPS());
379379
$_SERVER['HTTP_HOST'] = 'example.com:443';
@@ -482,7 +482,7 @@ public function testSetBaseURL()
482482
$expectedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php';
483483
$expectedRoutedUrlNQ2 = 'http://anothersp.example.com:81/example2/route.php';
484484
$expectedUrl2 = 'http://anothersp.example.com:81/example2/route.php?x=test';
485-
485+
486486
$this->assertEquals('http', OneLogin_Saml2_Utils::getSelfProtocol());
487487
$this->assertEquals('anothersp.example.com', OneLogin_Saml2_Utils::getSelfHost());
488488
$this->assertEquals('81', OneLogin_Saml2_Utils::getSelfPort());
@@ -957,7 +957,7 @@ public function testDeleteLocalSession()
957957
$this->assertTrue($_SESSION['samltest']);
958958

959959
OneLogin_Saml2_Utils::deleteLocalSession();
960-
$this->assertFalse(isset($_SESSION));
960+
$this->assertEmpty($_SESSION);
961961
$this->assertFalse(isset($_SESSION['samltest']));
962962

963963
$prev = error_reporting(0);
@@ -966,7 +966,7 @@ public function testDeleteLocalSession()
966966

967967
$_SESSION['samltest'] = true;
968968
OneLogin_Saml2_Utils::deleteLocalSession();
969-
$this->assertFalse(isset($_SESSION));
969+
$this->assertEmpty($_SESSION);
970970
$this->assertFalse(isset($_SESSION['samltest']));
971971
}
972972
}

0 commit comments

Comments
 (0)