I'm developing a PHP application for a camp in my church, so I need to check if the user is logged in to be able to redirect it if he is logged in and try to reload the login page and request access if he is not logged in , basically I want to redirect who has logged in so that he does not enter username and password again and, if not logged in, display the login page normally. That's the problem. I made a file for the functions that I will need and the login file, the paths of the files are correct, but it is giving this error here when I access the login.php
:
Notice: Undefined index: logged_in in /home/vol15_6/epizy.com/epiz_22599397/htdocs/applicacao/controller/functions.php online 16
On lines 14 - 21 of file functions.php
I have this here:
function isLoggedIn()
{
if (isset($_SESSION['logged_in']) || $_SESSION['logged_in'] == true)
{
return true;
}
return false;
}
In my file login.php
I have this call here:
<?php
if (isLoggedIn()) {
// Redireciona para dashboard
header("Location: /dashboard");
} else {
// Num faz nada
}
?>
<html>(muito html e css)</html>
What is causing the error and how can I fix it? If anyone knows, I'll be very grateful.