1 /* 设置cookie函数 */
2 function setCookie(key,value,day) {
3 var date=new Date();
4 date.setDate(date.getDate()+day);
5 document.cookie=key+'='+escape(value)+';expires='+date;
6 }
7 /* 获取cookie函数 */
8 function getCookie(key) {
9 var coo=unescape(document.cookie);//解码
10 var arr1=coo.split('; ');//第一次分解后是数组
11 for (var i=0;i<arr1.length;i++){//第二次循环拆分数组
12 var arr2=arr1[i].split('=');
13 if(arr2[0]==key){
14 return arr2[1];
15 }
16 }
17 }
18 /* 删除cookie */
19 function removeCookie(key) {
20 setCookie(key,'',-1);
21 }