系统登录时,选中记录帐号、密码,则会保存在COOKIE中;后续有效期内访问输入帐号,则自动带出密码
//设置Cookie
function setCookie(name, value, expdays){
let expdate = new Date();
//设置Cookie过期日期
expdate.setDate(expdate.getDate() + expdays);
//添加Cookie
document.cookie = name + "=" + escape(value) + ";expires=" + expdate.toUTCString();
}
//获取Cookie
function getCookie(name){
if(document.cookie.length>0){
//获取name在Cookie中起止位置
let start = document.cookie.indexOf(name + "=");
if(start != -1){
start = start + name.length + 1;
//获取value的终止位置
let end = document.cookie.indexOf(";", start);
if(end == -1){
end = document.cookie.length
};
//截获cookie的value值,并返回
return unescape(document.cookie.substring(start, end));
}
}
return "" ;
}
//清除Cookie
function delCookie(name){
setCookie(name, "", -1);
}