Mount my web application to a web server, locally everything works perfectly, requests among other things, I have a system of pages for registered and logged users, I manipulate them with sessions, verifications among other things, each page (registered users ) has a check in headers that is responsible for checking and validating users for security reasons through a backend code that I have, if the conditions are not met is to say that it does not pass through the verification system that I have not created the sessions and if the sessions are not created I send them to the index.php, here the code to better understand what I say.
<?php
session_start();
if(!isset($_SESSION['user']) || (!isset($_SESSION['nick'])) ){
header("Location: index.php?session=TimeOut");
exit();
}else{
if($_SESSION['user']!=$_SESSION['name_validate'] || $_SESSION['id']!=$_SESSION['id_user']||$_SESSION['user_validate']!=$_SESSION['permise'] || $_SESSION['data_validate']!=$_SESSION['random'] ){
header("Location: index.php?access=Denied");
exit();
}
}
?>
<!DOCTYPE html>
Also try this way:
<?php
/* Redirecciona a una página diferente en el mismo directorio el cual se hizo la petición */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>
//Del manual de PHP
As you can see they are before any entry in the html or data, so it should work, in addition the console does not mark any type of error, so I do not know where the problem is. In summary this code was made to avoid that users place the URL directly without logging in.