I am trying to make a site require username/password and I have achieved that using forms/cookies. I have 2 problems I can't figure out. When cookies are turned off or I go manually to one of the "secure" pages, the browser goes there and I can't prevent it. I have an if statement asking if the cookie is == '' and it recognizes that there is nothing there but it gives me an error saying that the variable ( that I call "cookie" which is the true or false statement that passes from the previous page letting the user log on or not) does not exist. I understand why but I guess my question is how can I make the browser redirect to an other page if there is no cookie there?
Hope I am understandable.
Cookie problem.
Moderator: General Moderators
it would help if you post your code, but this is a very basic outline of what you need to do
a lot of people still incorrectly do things w/ authentification, id suggest posting the code and letting people help you w/ it.
Code: Select all
if (empty($_COOKIE['username'])) {
header('Location: login.php');
exit;
} else {
// check thier credentials and if all ok, allow them in
}a lot of people still incorrectly do things w/ authentification, id suggest posting the code and letting people help you w/ it.
-
ecevdoxiadis
- Forum Newbie
- Posts: 2
- Joined: Fri Nov 12, 2004 2:59 am
Thanks
Thank you very much. I am relieved to see this working...