0
I am making a user authentication system based on SESSIONS. I created a function that makes the LOGOUT that is like this:
session_destroy(); // Cancela/Exclui a sessão iniciada
unset($_SESSION['usuario']);
?>
<script type="text/javascript">
location.href='index.php';
</script>
But by clicking the "back" button of the browser, the script is not pointing to the home page. I put the following code on the protected page:
session_start();
if(!isset($_SESSION['usuario'])){
header("Location: index.php?error=2");
}
On the authentication page, my code is like this:
$usuario= $row["usuario_id"];
$nivel = $row["nivel_usuario"];
$nome = $row["nome"];
$fnc = $row["funcao"];
session_start();
if($nivel == 2 ){
$_SESSION['adm'] = "$nome";
$_SESSION['usuario'] = "$usuario";
} else {
$_SESSION['nor'] = "$nome";
$_SESSION['usuario'] = "$usuario";
}
echo '<script type="text/javascript">window.location = "pages/index.php?fnc=' . $fnc . '"</script>';
}
} else {
echo '<script type="text/javascript">window.location = "index.php?erro=2"</script>';
}
}