I'm doing a simple login, where the user puts the data and takes it to the panel, but what I want to do is that if another user wants to enter that panel he can not access if he is not logged in.
If you know, please help me.
validate:
<?php
$miuser = "root";
$mipass = "1234";
if(isset($_POST['login'])) {
$usuario = $_POST['usuario'];
$pass = $_POST['password'];
if ($usuario == $miuser and $pass == $mipass ) {
if (isset($_POST['remember'])) {
setcookie('usuario', $usuario, time()+60*60*7);
setcookie('passowrd', $pass, time()+60*60*7);
}
session_start();
$_SESSION['usuario'] = $usuario;
header("location: feed.php");
} else {
echo "usuario o clave son incorrectos";
}
} else {
header("location: login.php");
}
?>
user panel:
<?php
session_start();
echo "Bienvenido" . $_SESSION['usuario'];
echo "<a href='salir.php'>salir</a>"
?>
salir.php
<?php
session_start();
session_destroy();
echo "has salido correctamente";
?>