JS操作Cookies的小例子
1 Cookie = {
2 setCookie: function (name, val) { 3 var exp = new Date(); 4 exp.setDate(exp.getDate() + 600 * 1000); 5 document.cookie = name + "=" + escape(val) + ";expires=" + exp.toGMTString(); 6 }, DelCookie: function (name) { 7 document.cookie = name + "=;expires=" + (new Date(0)).toGMTString(); 8 }, getCookie: function (name) { 9 var cookieArray = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)")); 10 if (cookieArray != null) return unescape(cookieArray[2]); 11 else return null; 12 } 13 }