Okay so now I am trying to restrict access to my landing page and the only way to access it should be by logging in and the code below is supposed to redirect the browser to the login page if the session is not set (a successful login sets the 'username' session)
if (!isset($_SESSION['username'])){
header('login.php');
}
I set up a small check that would notify me if the session is set or not
if(isset($_SESSION['username'])){
echo "Session is set!";
}
else{
echo "Session not set!";
}
and then i logged in so my code said "Session is set!", yey, now let's log out and try to access this page manually... few seconds later i land on my index page and the code says "Session not set!". So what am I doing on this page then? Shouldn't I be redirected to login.php?
So mt question here is do you know why is the (!isset... function not working and how can i fix it?
Aucun commentaire:
Enregistrer un commentaire