Verifying a login cookie : Login Form « Login Authentication « PHP






Verifying a login cookie

 
<?php
unset($username);
if ($_COOKIE['login']) {
    list($c_username,$cookie_hash) = split(',',$_COOKIE['login']);
    if (md5($c_username.$secret_word) == $cookie_hash) {
        $username = $c_username;
    } else {
        print "You have sent a bad cookie.";
    }
}

if ($username) {
    print "Welcome, $username.";
} else {
    print "Welcome, anonymous user.";
}
?>
  
  








Related examples in the same category

1.Login form with Error Messages and Preserving User Input
2.Hard code login Form
3.A More Sophisticated Login Page
4.A Simple Login Page
5.A Simple User Authentication Script
6.Log-In Page
7.View guestbook