I worked on protecting my site (PHP) and there was a lot of information to swallow. I tried to implement the security that I was researching on OWASP , but one thing that I'm a little nervous about, among other things, how to handle SESSIONS when a user logs out.
Currently, all I use is:
session_destroy();
But, I read that I have to change the XRSF token and run another SESSION to force the user to re-enter the credentials in turn, clearly ending the SESSION users.
Enough session_destroy()?
EDIT
I downloaded michael-the-messenger , which I think was created by Michael Rook, which should be VERY safe, and I saw some code that I can use. Is this something I can safely replace session_destroy()that I'm using?
CODE
if($_SESSION['user']->isAuth())
{
if($_POST['LogMeOut'] == 'true')
{
$tmp_xsrf = $_SESSION['user']->getXsrfToken();
$_SESSION['user']->logout();
$loginMessage = str_replace($tmp_xsrf, $_SESSION['user']->getXsrfToken(), $loginMessage);
print layout('Authorization Required', $loginMessage);
}
else
{
header("Location: inbox.php");
}
}
else
{
LOGOUT
public function logout()
{
$_SESSION['user'] = new auth();
}
Obviously $_SESSION['user'] = new auth();restores an object that sets the private variable $authto false.
source
share