0
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 that as a user deslogue
, there is a message saying that it was successful, however, the message does not appear, I did with access restriction to logado/deslogado
, and it worked, but I’m not getting through logout
In the archive
logicaUsuario.php
not ofunset
in thesuccess
?– Augusto
Someone must be killing the session before printing.
– ShutUpMagda
I added user logic to the question. @Shutupmagda, I tried to pass session_destroy after the message, but it still didn’t work
– Murilo Melo