1 回答
TA贡献10条经验 获得超5个赞
如果不用加密的话,用js就可以,其实就是一个记住用户名密码的功能
<body>
账号:<input>
密码:<input>
记住密码:<input type="checkbox">
<button onclick="fn()">登录</button>
<script>
var user = document.getElementsByTagName("input")[0],
pass = document.getElementsByTagName("input")[1],
check = document.getElementsByTagName("input")[2],
loUser = localStorage.getItem("user") || "";
loPass = localStorage.getItem("pass") || "";
user.value = loUser;
pass.value = loPass;
if(loUser !== "" && loPass !== ""){
check.setAttribute("checked","");
}
function fn(){
if(check.checked){
localStorage.setItem("user",user.value);
localStorage.setItem("pass",pass.value);
}else{
localStorage.setItem("user","");
localStorage.setItem("pass","");
}
}
</script>
</body>
添加回答
举报