1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
var cookies = {
set: function (name, value, expires, path, domain) { expires = new Date(new Date().getTime() + (((typeof expires == "undefined") ? 12 * 7200 : expires)) * 1000); var tempcookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "; path=/") + ((domain) ? "; domain=" + domain : ""); (tempcookie.length < 4096) ? document.cookie = tempcookie : alert("The cookie is bigger than cookie lagrest"); },
get: function (name) { var xarr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)")); if (xarr != null) return unescape(xarr[2]); return null; },
del: function (name, path, domain) { if (this.get(name)) document.cookie = name + "=" + ((path) ? "; path=" + path : "; path=/") + ((domain) ? "; domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; }, day: function (xd) { return xd * 24 * 3600; }, hour: function (xh) { return xh * 3600; } }
|