You need to put your script on an SSL-enabled directory first. Another is, after the user have successfully login. Generate 2 hash string. The first hash is called the DERIVED-KEYs: a hash created using
DERIVED-KEY1 = MD5("username" . "password" . $time() . "Your Sites Secret Key 1")
DERIVED-KEY2 = MD5( "password" . "username" . $time() . "Your Sites Secret Key 2")
... this is the hash string which will be applied to another HASH string called the AUTH-HASH. THe AUTH-HASH is a string derived by calling
md5(DERIVED-KEY1 . DERIVED-KEY2)
then, save it to cookie.
SetCookie("auth_hash", "$AUTH-HASH",0)
SetCookie("derived_key1", "$DERIVED-KEY1",0)
SetCookie("derived_key2", "$DERIVED-KEY2",0)
... save other cookie info if needed.
on each page always check the validity of of the AUTH-HASH by doing this,
$validkey = md5($derived_key1 . $derived_key2);
if ($validkey == $auth_hash) {
the user is valid....
}
else {
denied
}
remember, that when the user closed their browser, the cookie information (keys, and hashes) will be deleted automatically.
Try this, 🙂
Jun