JavaScript Cookie
function addCookie(name,value,expiresHours){ var cookieString=name+"="+escape(value); //判断是否设置过期时间 if(expiresHours>0){ var date=new Date(); date.setTime(date.getTime+expiresHours*3600*1000); cookieString = cookieString + "; expires=" + date.toGMTString() + ";path=/"; } document.cookie=cookieString; } function getCookie(name){ var strCookie=document.cookie; var arrCookie=strCookie.split(";"); for(var i=0;i<arrCookie.length;i++){ var arr=arrCookie[i].split("="); if (arr[0] == name) return arr[1]; } return ""; } function deleteCookie(name) { var date = new Date(); date.setTime(date.getTime() - 10000); document.cookie = name + "=v; expires=" + date.toGMTString() + ";path=/";; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。