Jump to content

PHP isset($_SESSION)


ncurran217

Recommended Posts

So I am new on using the SESSION variables in PHP. I have created a simple login screen. Not trying to be to secure with it, just wanted it to be a simple login so a certain field was filled in and the user cannot change the Rep field. Anyways, I have put this at the top of the page where it goes to when they login in the username and password are correct:

 

<?php
session_start();
if(isset($_SESSION['forteid']))
{
header("location: index.php");
}
else
{
header("location: login.php");
}
?>

 

When I log in the page comes up with:

 

This webpage has a redirect loop. The webpage at http://cslogs:8081/test/index.php has resulted in too many redirects. I am new with this so not sure how to fix this one or haven't found a way to attempt to fix it.

 

Basically I want it to where they can't just type in http://cslogs:8081/test/index.php in the address bar and get to the screen without logging in, which the login page is just login.php.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/272701-php-isset_session/
Share on other sites

You need a exit; statement after your header() redirect to prevent the rest of the code on your 'protected' page from running while the browser is preforming the redirect. Without an exit; to stop the script, all anyone needs to do is ignore the redirect and they can access your 'protected' pages the same as if you didn't have a log in system at all.

Link to comment
https://forums.phpfreaks.com/topic/272701-php-isset_session/#findComment-1403303
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.