Jump to content

User Login Problem


hhisc383

Recommended Posts

Hey everyone. I have a problem with User Login...

I have a script that, once someone logs in, it redirects them to a page specific to them. The only problem is, if they bookmark that page, they can go right back to it without logging in. I need a script that will do the following:

If anyone tries to go to the page that they are suppost to be redirected to without logging in, I need it to send them automatically back to the login page so they can log in.

Any ideas? Thanks
Link to comment
https://forums.phpfreaks.com/topic/34835-user-login-problem/
Share on other sites

the login isn't secure. if anyone types in the redirect address, they can view the page. i need something that will kick them out if they try to go without logging in. Here is a script I got that I coudln't get to work...but it might just be because i'm new to PHP:

php:

session_start();
if (login is valid)
{
  $_SESSION['loggedin'] = true;
}


then on the page you are trying to protect, at the top of the page


php:

session_start();
if (!isset($_SESSION['loggedin']))
{
  header('Location: http://domain.com/login/');
  exit();
}
Link to comment
https://forums.phpfreaks.com/topic/34835-user-login-problem/#findComment-164213
Share on other sites

this is how it checks the login information:


session_start();

//check to see if the user already has an open session
if (($_SESSION[user_name] != "") && ($_SESSION[password] != ""))
{
header("Location:$_SESSION[redirect]");
exit;
}

//check to see if cookies have been set previously
if(($lr_user != "") && ($lr_pass != ""))
{
header("Location:redirect.php");
exit;
}

//if neither is true, redirect to login
header("Location:login.php");
Link to comment
https://forums.phpfreaks.com/topic/34835-user-login-problem/#findComment-164227
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.