代码
//读取COOKIE的用户名和密码的值即可
if($_COOKIE['uname']!=''){$CKUNAME = $_COOKIE['uname'];}
if($_COOKIE['pwd']!=''){$CKPWD = $_COOKIE['pwd'];}
echo $CKUNAME;
echo '
';
echo $CKPWD;
?>
type="password" name="pwd" id="pwd" value="=$CKPWD;?>" />
name="remember" type="checkbox" value="1" if($CKUNAME!=''){?>
checked="checked" } ?> /> 记住我!
id="button" value="登录" />
//登录,将用户名和密码存入到COOKIE
if($_POST['button']!=''){
$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
//如果输入的加密密码和COOKIE中不一样,那么就加密
if($pwd!=$CKPWD){$pwd = md5($pwd);}
$remember = $_POST['remember'];
if($remember==1){
setcookie("uname", $uname, time()+3600*24*30);
setcookie("pwd", $pwd, time()+3600*24*30);
}
}
?>
本文原创发布php中文网,转载请注明出处,感谢您的尊重!