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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.