function setCookie(name, value, expiredays) {
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + "=" + value + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCookie(name) {
var start, end;
var i = 0;
while (i <= document.cookie.length) {
start = i;
end = start + name.length;
if (document.cookie.substring(start, end) == name) {
start = end + 1;
end = document.cookie.indexOf(";", start);
if (end < start)
end = document.cookie.length;
return document.cookie.substring(start, end)
}
i++
}
return ""
}

만료일을 지정하여 해당날짜까지 쿠키에 저장.

+ Recent posts