php使用cookie实现记住用户名和密码实现代码

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <form method="post" action="check_remember.php"> <table cellpadding="0" cellspacing="0"> <thead> <tr> <td colspan="2"><b>记住用户名和密码</b></td> </tr> </thead> <tr> <td>用 户 名:</td> <td><input type="text" value="<?php echo $_COOKIE['name'];?>"></td> </tr> <tr> <td>密码:</td> <td><input type="password" value="<?php echo $_COOKIE['password']?>"></td> </tr> <tr> <td>记住用户名和密码</td> <td><?php if($_COOKIE['remember'] == 1){?><input type="checkbox" value="1" checked><?php }else{($_COOKIE['remember'] == "")?><input type="checkbox" value="1"><?php }?></td> </tr> <tr> <td colspan="2"><input type="submit" value="提交" /></td> </tr> </table> </form> check_remember.php <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $name = $_POST['name']; $password = $_POST['password']; $remember = $_POST['remember']; if($remember == 1){ setcookie('name',$name,time()+3600); setcookie('password',$password,time()+3600); setcookie('remember',$remember,time()+3600); }else{ setcookie('name',$name,time()-3600); setcookie('password',$password,time()-3600); setcookie('remember',$remember,time()-3600); } echo "<a href=https://www.jb51.net/article/\"remember.php\">返回</a>"; ?>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/68c2581beff0558d1877c0a012b32f51.html