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

// 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}}
    -
제목 작성자 날짜
공대여자
공대여자
mins01
mins
mins
mins
mins
mins
mins
mins
mins
mins
mins
mins
mins
mins
mins
mins