-
-
Notifications
You must be signed in to change notification settings - Fork 498
Empty instead of unset the $_SESSION variable #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We shouldn't destroy a global variable cause other scripts trust them to be there.
lib/Saml2/Utils.php
Outdated
| } | ||
|
|
||
| unset($_SESSION); | ||
| $_SESSION = []; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
lib/Saml2/Utils.php
Outdated
| { | ||
|
|
||
| if (OneLogin_Saml2_Utils::isSessionStarted()) { | ||
| session_unset(); |
There was a problem hiding this comment.
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();
}There was a problem hiding this comment.
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();
}There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes done! 💪
|
I had to revert it, the test failed.
|
|
Whoops 😬 I’ll check it out tomorrow
Verstuurd vanaf mijn iPhone
… Op 5 dec. 2019 om 19:00 heeft Sixto Martin ***@***.***> het volgende geschreven:
I had to revert it, the test failed.
OneLogin_Saml2_AuthTest::testProcessSLOResponseValidDeletingSession
Failed asserting that true is false.
/home/travis/build/onelogin/php-saml/tests/src/OneLogin/Saml2/AuthTest.php:560
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
We shouldn't destroy a global variable cause other scripts trust them to be there.
For instance the
savemethod of the SymfonyNativeSessionStoragetrusts the variable to be there.Assigning an empty array to the variable would do the trick.