cookie应用(一周内免登陆)
发布日期:2021-08-13 04:05:36 浏览次数:49 分类:技术文章

本文共 993 字,大约阅读时间需要 3 分钟。

<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="md5.js" type="text/javascript" charset="utf-8"></script>
<script src="public.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<label for="">用户名:</label><input type="text" /><br />
<label for="">密 码:</label><input type="password" /><br />
<input type="checkbox"/>记住用户名和密码<br />
<input type="button" value="登录" />
<script type="text/javascript">
var aInput=document.getElementsByTagName('input');
if(getCookie('username') && getCookie('password')){
aInput[0].value=getCookie('username');
aInput[1].value=getCookie('password');
aInput[2].checked=true;
}
aInput[3].οnclick=function(){
//alert(getCookie('sex'));//undefined:如果cookie值不存在输出undefined
if(aInput[2].checked){
addCookie('username',aInput[0].value,7);
addCookie('password',hex_md5(aInput[1].value),7);
}else{
delCookie('username');
delcookie('password');
}
}
</script>
</body>
</html>

转载于:https://www.cnblogs.com/xuxiaoxia/p/6710740.html

转载地址:https://blog.csdn.net/weixin_30675247/article/details/98989561 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:SQL获取本周,上周,本月,上月第一天和最后一天[注:本周从周一到周天]
下一篇:Mac锁屏快捷键

发表评论

最新留言

不错!
[***.144.177.141]2024年04月12日 12时19分50秒