By entering the valid user and password, the system creates a CONTROL variable to which the value of 1 is assigned.
LOGIN.PHP:
<?php
require ('includes/config.php');
if (isset($_POST['user'])) {
$usuariodao = new UsuarioDAO();
$u = $usuariodao->login($_POST['user'], $_POST['password']);
if($u){
$_SESSION['USUARIO_ACTUAL'] = serialize($u);
$_SESSION['CONTROL'] = 1;
header("Location: index2.php");
exit;
} else {
$tpl = new Plantilla();
$tpl->assign('ErrorLogin', "Usuario y/o Clave incorrectos");
$tpl->display("login.tpl.php");
}
}
?>
INDEX2.PHP:
<?php
require ('includes/config.php');
if ($_SESSION['CONTROL'] !== 1) {
header("Location: index.php"); <-- EJECUTAR SI "CONTROL" no fue definido.
exit;
}
echo "EXITO";
//---- CODIGO QUE SE EJECUTARÁ
?>
If the password and username are correct, it shows "SUCCESS" and in the bar it is: link But if I open another window and copy the url it shows "SUCCESS". It does not enter to execute INDEX.PHP. But if I close the browser and paste the URL link , it executes the header redirecting to index.php. What is the problem?