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