function init(form)
{
form.idCheck.checked = ((form.userId.value = getCookie("userId")) != "");
}
// 쿠키 조회
function getCookie(userId){
var search = userId + "="
if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면
offset = document.cookie.indexOf(search)
if (offset != -1) { // 쿠키가 존재하면
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset)
// 쿠키 값의 마지막 위치 인덱스 번호 설정
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
return "";
}
// 쿠키 저장
function saveCookie(form){
var expdate = new Date();
if (form.idCheck.checked){
expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 30); // 30일
}else{
expdate.setTime(expdate.getTime() - 1); // 쿠키 삭제조건
}
setCookie("userId", form.userId.value, expdate);
}
// 쿠키 생성
function setCookie(name, value, expiredays)
{
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + expiredays.toGMTString() ;
}