I am generating a login log I am integrating session_start();
I have an inconvenience, it marks me an error which is the following: Notice: Undefined index: tiempo in C:\xampp\htdocs\revista\rev\administrador\consultar_registros.php on line 26
, line 26 is the following: if(time() - $_SESSION['tiempo'] > 18000) {
I leave the code that I am using, I hope help me to solve this problem because I do not find that it should be I'm going crazy with this and I do not know how to solve it.
funcional.php
public function verificar_login($nombre_usuario, $password){
$sql = "SELECT * FROM usuario where nombre_usuario ='$nombre_usuario' and password = '$password' ";
$result = $this->conecta()->query($sql);
if($result->num_rows > 0){
while ($row = $result->fetch_assoc()) {
session_start();
$_SESSION['nombre_usuario'] = $row['nombre_usuario'];
$_SESSION['password'] = $row['password'];
$_SESSION["autentificado"] = "SI";
$_SESSION['start'] = date("Y-n-j H:i:s");
$_SESSION['tiempo'] = time();
if ($result->num_rows > 0)
header("Location:consultar_registros.php");
}
}else{
echo '<script language="javascript">
alert("Los datos son incorrectos vuelve a intentarlo");
window.location.href="../administrador/index.php";
</script>';
}
}
consult_registers.php
<?php
session_start();
if(time() - $_SESSION['tiempo'] > 18000) { ---Aquí es donde me indica que esta el error---
echo '<script language="javascript">
alert("Debes de registrarte para poder ingresar");
window.location.href="index.php";
</script>';
session_destroy();
}
?>