I want my login to verify if a session exists or if it doesn't allow me to start a session, this is my code that I add inside login:
<?php
session_start();
if($_SESSION['type'] == 1){
//en caso de que se detecte un inicio de sesión usuario se redireccionará al menú del sistema
header("location: views/user/index.php");
}
if($_SESSION['type'] == 2){
//en caso de que se detecte un inicio de sesión administrador se redireccionará al menú del sistema
header("location: views/admin/index.php");
}
When loading the login without the session started, it sends me the message
Notice: Undefined index: type in C:\xampp\htdocs\videos\consulta.php on line 46
Notice: Undefined index: type in C:\xampp\htdocs\videos\consulta.php on line 50
but if I am logged in it directs me fine to the views of each user
As you confirmed in the comments of this answer you want something like this:
That is, with the conditional it is verified if the key exists
type
within the $_SESSION variable, which I check with the isset() function , and if it is true, the rest of the verifications are carried out. Otherwise nothing happens and the error is avoided, as the OP wants.