hmm.... I dunno about the session_is_registered function.
That's also not secure, really, 'cause all they need is a username.
Here's what I'd do:
they log in.
their password and username are stored as session vars, or cookie vars, whatever.
at the top of the member page and anything else that requires login, have this code:
(***assume that $pass and $user are from the session/cookie vars... get those how you want)
PHP Code:
<?php
$query = "SELECT [*password*] FROM [*table*] WHERE [*username*]=$user";
$result= mysql_assoc(mysql_query($query));
if ($result['password'] != $pass) {
die("REDIRECT HERE");
}
//THEN PUT THE REST OF YOUR STUFF HERE, and it'll only be accessible
//if their stored pass = the pass they logged in with.
//The die("") function will end execution of the page, sending no data after it;
//they won't get the stuff after the login check,
//even for a split second before they're redirected.
?>
In short, just have it check at the top of the page whether for password in the database for the username is equal to the password they have in their cookie/sessionvar from logging in.
Random note: if you want to not store the person's actual password, you could use md5() to encrypt it.
Basically, it takes a string, and outputs a 32 character string that will be the same for the same input, but is irreversible...
if your password is "abc" then md5("abc") will always be the same, but you can't ever figure out what the password is from the stored md5 value.
it feels more moral in some ways.
Also, all you have to do then is, when the log in, have it check if the md5 of their password equals the stored md5 value for their password; if they are equal, then the passwords are also equal, but its more secure for people.
this is unrelated and not neccessary, but nice to know.
Bookmarks