1 //设置cookie
2 function setCookie(name, value, day) {
3 var oDate = new Date();
4 oDate.setDate(oDate.getDate() + day);
5 document.cookie = name + '=' + value + ';expires=' + oDate;
6 }
7 //删除cookie
8 function delCookie(name) {
9 setCookie(name, 1, -1);
10 }
11
12 //获取cookie
13 function getCookie(name) {
14 var arr = document.cookie.split('; ');
15 for(var i = 0; i < arr.length; i++) {
16 var arrName = arr[i].split('=');
17 if(arrName[0] == name) {
18 return arrName[1];
19 }
20 }
21 return '';
22 }