I have a login.php in which a user is valid, and if it is the correct one, I open the session. The code is as follows:
if (password_verify($pass,$resultado)) {
session_start();
$_SESSION['nick'] = $nickjugador;
$_SESSION['instante'] = time();
echo "Enhorabuena ".$_SESSION['nick'].", te has logueado, puedes acceder a <a href='cpanel.php'>Panel de control</a>";
}
else {
die(
"El nombre o la contraseña no coinciden");
}
In cpanel php I want to calculate the difference between the time in which the session was started and if the difference is of 3 and a half hours, or of 4 hours, that the session is closed. However when I do a vardump of datediff()$diferencia = date_diff($_SESSION['instante'], $fechanueva);
it returns a Boolean value.