핵심 코드:
var cookie= {
setCookie:function (이름, 값, iDay) {
var oDate = new Date()
oDate.setDate(oDate.getDate() iDay)
document.cookie = 이름 ' =' value ';expires=' oDate;
},
getCookie:function (name) {
var arr = document.cookie.split('; ')>for (var i = arr.length - 1; i >= 0; i--) {
var arr2 = arr[i].split('=')
if(arr2[0]===name)
return arr2[1];
}
}
return '';
},
removeCookie:function(이름) {
cookie.setCookie(name,1, -1) ;
}
}
테스트: