标签:
//记录cookie值 function setCookie (name,value){ var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); }; //获取cookie值 function getCookie (name){ var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr !== null){ return unescape(arr[2]); }else{ return null; } }; //删除cookie值 function deleteCookie (name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); document.cookie = name + "=; expires=" + exp.toGMTString(); };
cookie的部分操作,注cookie的值只能是string,如果想记录多个,只能操作字符串。
标签:
原文地址:http://www.cnblogs.com/xizai/p/4303041.html