session_destroy does not initialize new session

0

I'm trying to use the code below for when the user clicks exit, it is redirected to the file below to destroy the session, however after the destroyed session it can not log in again because the following page after login does not loads, only the name of the next page appears in the address bar.

Page that contains the 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 the function to exit:

session_start();

    unset ($_SESSION['usuariosession']);

    unset ($_SESSION['senhasession']);

    session_destroy();
    header('Location:views/login.php/');
    
asked by anonymous 24.01.2018 / 19:11

1 answer

1

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

    
25.01.2018 / 00:48