<mce:script type="text/javascript"><!-- function SetCookie(name,value,expire) { var exp = new Date(); exp.setTime(exp.getTime() + expire); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); } function getCookie(name) { var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null; } function delCookie(name){ var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=getCookie(name); if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); } // --></mce:script> JavaScript Cookie封装类源码 String.prototype.format = function() { var s = this; for (var i = 0, j = arguments.length; i < j; i++) s = s.replace("{" + (i) + "}", arguments[i]); return(s); } var Cookie = { Set : function () { var name = arguments[0], value = escape(arguments[1]), days = (arguments.length > 2) ? arguments[2] : 365, path = (arguments.length > 3) ? arguments[3] : "/"; with(new Date()) { setDate(getDate() + days); days = toUTCString(); } document.cookie = "{0}={1};expires={2};path={3}".format(name, value, days, path); }, Get : function () { var returnValue = document.cookie.match(new RegExp("[/b/^;]?" + arguments[0] + "=([^;]*)(?=;|/b|$)","i")); return returnValue ? unescape(returnValue[1]) : returnValue; }, Delete : function () { var name = arguments[0]; document.cookie = name + "=1 ; expires=Fri, 31 Dec 1900 23:59:59 GMT;"; } } 使用方法: <mce:script type="text/javascript"><!-- Cookie.Set("MyCookie", "Cookie值"); Cookie.Get("MyCookie"); Cookie.Delete("MyCookie") // --></mce:script>