Skip to content

Conversation

@SwenVanZanten
Copy link
Contributor

We shouldn't destroy a global variable cause other scripts trust them to be there.
For instance the save method of the Symfony NativeSessionStorage trusts the variable to be there.

Assigning an empty array to the variable would do the trick.

We shouldn't destroy a global variable cause other scripts trust them to be there.
@SwenVanZanten SwenVanZanten changed the title Empty the $_SESSION variable instead of unset Empty instead of unset the $_SESSION variable Dec 5, 2019
}

unset($_SESSION);
$_SESSION = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PHP has a method for this: session_unset, see: https://www.php.net/manual/en/function.session-unset.php

They even left a note about how it's really wrong to unset the $_SESSION variable entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one, I checked this function out, yet it didn't work for me.
However I called the function after the session_destroy function was called.
It seems that doesn't work.

I'll adjust the pully

{

if (OneLogin_Saml2_Utils::isSessionStarted()) {
session_unset();
Copy link
Contributor

@pitbulk pitbulk Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

if (OneLogin_Saml2_Utils::isSessionStarted()) {
    session_unset();
    session_destroy();
} else {
    session_unset();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, however I suggest to put the unset before the destroy without the else:

session_unset();

if (OneLogin_Saml2_Utils::isSessionStarted()) {
    session_destroy();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, modify the PR and I will merge, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes done! 💪

@pitbulk pitbulk merged commit cc4d849 into SAML-Toolkits:master Dec 5, 2019
@pitbulk
Copy link
Contributor

pitbulk commented Dec 5, 2019

I had to revert it, the test failed.

  1. OneLogin_Saml2_AuthTest::testProcessSLOResponseValidDeletingSession
    Failed asserting that true is false.
    /home/travis/build/onelogin/php-saml/tests/src/OneLogin/Saml2/AuthTest.php:560

@SwenVanZanten
Copy link
Contributor Author

SwenVanZanten commented Dec 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants