hhisc383 Posted January 19, 2007 Share Posted January 19, 2007 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 Quote Link to comment Share on other sites More sharing options...
trochia Posted January 19, 2007 Share Posted January 19, 2007 use cookies, sounds like you are not expiring after the logged session ends Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 check if they are logged in on the page, and if not, send back. It depends on how you're doing your "login" Quote Link to comment Share on other sites More sharing options...
hhisc383 Posted January 19, 2007 Author Share Posted January 19, 2007 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 pagephp:session_start();if (!isset($_SESSION['loggedin'])){ header('Location: http://domain.com/login/'); exit();} Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 What doesn't work? Errors, what? The fact that if (login is valid) isn't actually code? We can't help you unless you describe an actual problem, not just a vague problem. Quote Link to comment Share on other sites More sharing options...
hhisc383 Posted January 19, 2007 Author Share Posted January 19, 2007 ok the first code comes up with this error:Parse error: parse error, unexpected ')' in /home/content/l/a/s/lastdetailwd/html/login/login.php on line 3I don't know what's wrong with it... Quote Link to comment Share on other sites More sharing options...
hhisc383 Posted January 19, 2007 Author Share Posted January 19, 2007 i'm new to php...sorry. does something else have to be changed in this line:if (login is valid)should (login is valid) be something else? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 Does that look like code? I mean, you can write code which looks pretty similar to english, but that contains no variables, functions, or operators. It's just English. Quote Link to comment Share on other sites More sharing options...
hhisc383 Posted January 19, 2007 Author Share Posted January 19, 2007 yes i know. it's the script that was given to me. i'm not sure what to change it to. do you have any idea what it should be so it will work? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 No, I didn't write your login form either.How does the system check if a username and password are right? That's what you need to check I guess. Quote Link to comment Share on other sites More sharing options...
hhisc383 Posted January 19, 2007 Author Share Posted January 19, 2007 this is how it checks the login information:session_start();//check to see if the user already has an open sessionif (($_SESSION[user_name] != "") && ($_SESSION[password] != "")){ header("Location:$_SESSION[redirect]"); exit;}//check to see if cookies have been set previouslyif(($lr_user != "") && ($lr_pass != "")){ header("Location:redirect.php"); exit;}//if neither is true, redirect to login header("Location:login.php"); Quote Link to comment Share on other sites More sharing options...
trochia Posted January 19, 2007 Share Posted January 19, 2007 are variables set?http://us3.php.net/manual/en/function.session-start.php Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 19, 2007 Share Posted January 19, 2007 How do the cookies and session ever start though? This is a bit insane. I hope someone with a longer temper comes to help you. Good luck. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.