// 쿠키 값 설정
function setCookie(name, value, days) {
    let expires = "";
    if (days) {
        const date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); // 일(day) 단위로 유효 기간 설정
        expires = ("; expires=" + date.toUTCString());
    }
    document.cookie = (name + "=" + encodeURIComponent(value) + expires + "; path=/");
}

// 쿠키 값 조회
function getCookie(name) {
    const nameEQ = name + "=";
    const cookies = document.cookie.split(';');
    for (let i = 0; i < cookies.length; i++) {
        let cookie = cookies[i];
        while (cookie.charAt(0) === ' ') {
            cookie = cookie.substring(1, cookie.length); // 공백 제거
        }
        if (cookie.indexOf(nameEQ) === 0) {
            return decodeURIComponent(cookie.substring(nameEQ.length, cookie.length));
        }
    }
    return null;
}

// 쿠키 삭제
function deleteCookie(name) {
    document.cookie = (name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;");
}