How to deny access to a page without first going through startup?

-3

How do I make a user not enter a route without first going through the start?

example:

public_html/proyecto/pagina_contenido.html

I need that before I enter that page I am obliged to go through:

public_html/proyecto/inicio.html 

for eventually from inicio.html to be redirected to the page with content.

    
asked by Nicolás Poblete Marchan't 09.11.2017 в 16:35
source

1 answer

0

To control access, it is best to manage access through sessions.

in your file pagina_contenido.php you search for the session variable, if it has no value, you redirect to inicio.php with the appropriate heading.

home.php

//Primera línea siempre
session_start();
//en algún momento guardas la variable de sesión 
$_SESSION['registrado'] = true;

pagina_contenido.php

if(!$_SESSION['registrado']){
   //encabezado de redirección
   header("location:inicio.php");
   die;
}
    
answered by 09.11.2017 / 16:56
source