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
|
var setCookie = function (name, value, day) { if(day !== 0){ var expires = day * 24 * 60 * 60 * 1000; var date = new Date(+new Date()+expires); document.cookie = name + "=" + escape(value) + ";expires=" + date.toUTCString(); }else{ document.cookie = name + "=" + escape(value); } };
var getCookie = function (name) { var arr; var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)){ return unescape(arr[2]); } else{ return null; } };
var removeCookie = function (name) { setCookie(name, ' ', -1); };
|