LogicaUsuario.php
<?php
session_start();
function usuarioEstaLogado(){
return isset($_SESSION["usuario_logado"]);
};
function verificaUsuario(){
if (!usuarioEstaLogado()){
$_SESSION["danger"] = "Você não tem acesso a essa funcionalidade";
header("Location: index.php");
die();
};
};
function usuarioLogado(){
return $_SESSION["usuario_logado"];
};
function logaUsuario($email){
$_SESSION["usuario_logado"] = $email;
};
function logOut(){
session_destroy();
};
index.php
<?php
include("header.php");
include("logicaUsuario.php");
if(isset($_SESSION["success"])):
?>
<div class="alert-box">
<p class="alert success"><?= $_SESSION["success"] ;?></p>
</div>
<?php
;elseif(isset($_SESSION["danger"])):
?>
<div class="alert-box">
<p class="alert error"><?= $_SESSION["danger"] ;?></p>
</div>
<?php
;endif;
unset($_SESSION["success"]);
unset($_SESSION["danger"]);
?>
<div class="container">
</div>
<?php include("footer.php"); ?>
Logout.php
<?php
include("logicaUsuario.php");
verificaUsuario();
logOut();
$_SESSION["success"] = "Deslogado com sucesso";
header("Location: index.php");
I'm trying to make sure that when user deslogue
appears a message saying that it was successful, however, the message does not appear, I made access restriction to logado/deslogado
, and it worked, but I'm not able to with logout