引入cdn
function saveUserInfo() {
console.log("saveUserInfo cookie!")
//使用cookie记住账号密码 (单纯的不想每次都手写了), 登录成功时调用
if ($("#remember_account").prop("checked") == true) {
var account_sid = $("#account_sid").val();
var account_pwd = $("#account_pwd").val();
$.cookie("remember_account", "true", {
expires: 7
}); // 存储一个带7天期限的 cookie
$.cookie("account_sid", account_sid, {
expires: 7
}); // 存储一个带7天期限的 cookie
$.cookie("account_pwd", account_pwd, {
expires: 7
}); // 存储一个带7天期限的 cookie
} else {
$.cookie("remember_account", "false", {
expires: -1
}); // 删除 cookie
$.cookie("account_sid", '', {
expires: -1
});
$.cookie("account_pwd", '', {
expires: -1
});
}
}
自动写入:
//如果含有该cookie,自动填写账号密码
if ($.cookie("remember_account")) {
console.log($.cookie("remember_account"))
$("#remember_account").prop("checked", true);
$("#account_sid").val($.cookie("account_sid"));
$("#account_pwd").val($.cookie("account_pwd"));
}else {
console.error("cookie get error")
}