JS设置cookie setcookie getcookie
//获取cookie值 function getCookie(name) { //document.cookie.setPath("/"); var arr, reg = new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)) { return unescape(arr[2]); } else { return null; } } //设置cookie值 function setCookie(name,value) { //document.cookie.setPath("/"); var hour = 8; var exp = new Date(); exp.setTime(exp.getTime() + hour*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/"; }