现在基本上很少使用cookie了吧 很多浏览器都会有记住密码功能
<div class=" ipt">
<input
type="text"
id="txt_username"
placeholder="请输入账号"
>
</div>
<div class="ipt">
<input
type="password"
id="txt_password"
placeholder="请输入密码"
>
</div>
<label class="fl"><input type="checkbox" id="ck_rmbUser">一周内记住密码</label>
cookie(){
if ($.cookie("rmbUser") == "true") {
this.zhanghao = $.cookie("username");
this.password = $.cookie("password");
$("#ck_rmbUser").attr("checked",true);
}
},
save(){
if ($("#ck_rmbUser").prop("checked")) { // 记住信息7天
var str_username = $("#txt_username").val();
var str_password = $("#txt_password").val();
$.cookie("rmbUser", "true", { expires: 7 });
$.cookie("username", str_username, { expires: 7 });
$.cookie("password",str_password, { expires: 7 });
}else {
if($.cookie("rmbUser") == false){ // 清除
$.cookie("rmbUser", "false", { expire: -1 });
$.cookie("username", "", { expires: -1 });
$.cookie("password", "", { expires: -1 });
}else{
$.cookie("rmbUser", false);
$.cookie("password", null);
}
}
}