session_destroy does not start new session

Asked

Viewed 110 times

0

I am trying to use the code below so when the user clicks exit, it is redirected to the file below destroy the session, but after destroyed the session is not possible to login again, because the following page after login does not load, only the name of the next page appears in the address bar.

Page containing login functions:

session_start();

$_SESSION['usuariosession'] = $user;
$_SESSION['senhasession'] = $pass;
$_SESSION['autenticandosession'] = true;

header('Location:views/painel.php/');

Next page after login:

session_start();

    if(!isset($_SESSION['autenticandosession']) || $_SESSION['autenticandosession'] != true){
        echo "Acesso não autorizado </br>";
        echo "Por favor faça seu login <a href='login.php'> clicando aqui </a>";
        exit();
    }else{
        echo "<p> Bem vindo ".ucfirst($_SESSION['usuariosession'])."</p> </br>";
    }


<html>
<head> 
    <title> Painel </title>
</head>

<body>
    <h1> Olá eu sou o painel, se voce chegou até aqui é porque suas credenciais deram certo... </h1>

    <a href="../sair.php"> Sair </a>
</body>
</html>

Page with exit function:

session_start();

    unset ($_SESSION['usuariosession']);

    unset ($_SESSION['senhasession']);

    session_destroy();
    header('Location:views/login.php/');

1 answer

1


In login.php you are redirecting to /view/painel.php and in the exit.php is directing to views/login.php. And there is no login.php in this view directory.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.