Logged-in user can login to their login page

0

When the user logs in he creates sessions and goes to the panel, but he continues with access to the login page. how to send it back to the panel.php when it tries to go to the login page?

sessions:

$user = $_POST['usuario'];
$_SESSION['user'] = $user;
$_SESSION['status'] = 'LOGADO';
$_SESSION['usuario'] = $busca ['usuario'];
$_SESSION['senha'] = $busca ['senha'];
    
asked by anonymous 01.08.2018 / 02:58

1 answer

1

2 examples:

Option 1

(will have to change its structure)

You will give include as logged in or not:

if(isset($_SESSION['status'])) {
   include_once 'painel.php';
} else {
   include_once 'login.php;
}

Option 2

(for your case of not letting in the login page, and not changing its structure)

Check the login page if the session exists, if so, go to the content page:

if (!isset($_SESSION['status'])) header('Location: painel.php');
    
01.08.2018 / 13:07