1.保存cookie
var oDate = new Date(); oDate.setDate(oDate.getDate() + 30);//有效期为30天 document.cookie = "name=www.wzh.com;expires=" + oDate;
2.读取cookie
var res = document.cookie.substring(5); if (res != "www.wzh.com") { alert("没有cookie信息"); }
时间: 2024-10-20 20:27:24