1.
//1.设置Cookie
function setCookie(name,value,days) {var date = new Date();date.setDate(date.getDate() + days);document.cookie = name + "="+ value + ";expires="+ date;
}
console.log(setCookie("pwd","5566778899",1));
//获取cookie
function getCookie(name) {var cookies = document.cookie.split(";");for(var i = 0, len = cookies.length; i < len; i++){var map = cookies[i].split("=");if (name == map[0]){return map[1];}}return false;//first time
}
alert(getCookie("pwd"))//删除cookie
function removeCookie(name){setCookie(name,1,-1);
}
removeCookie("pwd");
alert(document.cookie)