자바스크립트 쿠키 제어 함수

// http://www.qindex.info/Q_frame.php?s_clss=board&s_prcss=thrd&s_tmplt=&s_brd=5&s_thrd=33

function Q_getDateOfExpire(year,day,hour,minute,second) {
var today = new Date();
var exprs = new Date();
exprs.setTime( today.getTime()
+1000*60*60*24*365*year
+1000*60*60*24 *day
+1000*60*60 *hour
+1000*60 *minute
+1000 *second );
return exprs;
}

/*
String name, value
Date expires
String path, domain
Boolean secure

optional: expires,path,domain,secure
*/
function Q_setCookie(name,value,expires,path,domain,secure) {
document.cookie = name + '=' + escape(value) + ';'
+ ((expires) ? ' expires=' + expires.toGMTString() + ';' : '')
+ ((path) ? ' path=' + path + ';' : '')
+ ((domain) ? ' domain=' + domain + ';' : '')
+ ((secure) ? ' secure' + ';' : '');
}

// Returns a string or false
function Q_getCookie(name) {
var srch = name + '=';
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(srch);
if (offset != -1) {
offset += srch.length;
end = document.cookie.indexOf(';', offset);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(offset, end));
} else return false;
} else return false;
}

// optional: path,domain
function Q_deleteCookie(name,path,domain) {
if (Q_getCookie(name))
document.cookie = name + '=;'
+ ' expires=Thu, 01-Jan-70 00:00:01 GMT;'
+ ((path) ? ' path=' + path + ';' : '')
+ ((domain) ? ' domain=' + domain + ';' : '');
}
댓글
  • No Nickname
    No Comment
  • 권한이 없습니다.
    {{m_row.m_nick}}
    -
목록형 📷 갤러리형
제목
[기본형] HTML (with 부트스트랩5.3 , jquery 3.7, vue.js)
유용한 리눅스(LINUX) 명령어
[공지] 기술 게시판
4.28
4.29
4.30
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13
5.14
5.15
5.16
5.17
5.18
5.19
5.20
5.21
5.22
5.23
5.24
5.25
5.26
5.27
5.28
5.29
5.30
5.31
6.1