생성
function setCookie( cookieName, cookieValue, expireDate )
{
var today = new Date();
today.setDate( today.getDate() + parseInt( expireDate ) );
document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";"
}
setCookie('이름','값',시간);
사용 불러오기
function getCookie( cookieName ){
var search = cookieName + "=";
var cookie = document.cookie;
// 현재 쿠키가 존재할 경우
if( cookie.length > 0 ){
// 해당 쿠키명이 존재하는지 검색한 후 존재하면 위치를 리턴.
startIndex = cookie.indexOf( cookieName );
// 만약 존재한다면
if( startIndex != -1 ){
// 값을 얻어내기 위해 시작 인덱스 조절
startIndex += cookieName.length;
// 값을 얻어내기 위해 종료 인덱스 추출
endIndex = cookie.indexOf( ";", startIndex );
// 만약 종료 인덱스를 못찾게 되면 쿠키 전체길이로 설정
if( endIndex == -1) endIndex = cookie.length;
// 쿠키값을 추출하여 리턴
return unescape( cookie.substring( startIndex + 1, endIndex ) );
} else{ // 쿠키 내에 해당 쿠키가 존재하지 않을 경우
return false;
}
} else { // 쿠키 자체가 없을 경우
return false;
}
}
getCookie('이름);
삭제
function deleteCookie( cookieName )
{
var expireDate = new Date();
//어제 날짜를 쿠키 소멸 날짜로 설정한다.
expireDate.setDate( expireDate.getDate() - 1 );
document.cookie = cookieName + "= ; expires=" + expireDate.toGMTString() + "; path=/";
}
deleteCookie('이름');
게시판 목록
팁게시판
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5902 | 9년 전 | 302 | ||
| 5901 | 9년 전 | 322 | ||
| 5900 | 9년 전 | 323 | ||
| 5899 | 9년 전 | 795 | ||
| 5898 | 9년 전 | 282 | ||
| 5897 | 9년 전 | 290 | ||
| 5896 | 9년 전 | 208 | ||
| 5895 | 9년 전 | 739 | ||
| 5894 | 9년 전 | 360 | ||
| 5893 | 9년 전 | 348 | ||
| 5892 | 9년 전 | 401 | ||
| 5891 | 9년 전 | 406 | ||
| 5890 | 9년 전 | 456 | ||
| 5889 | 9년 전 | 319 | ||
| 5888 | 9년 전 | 212 | ||
| 5887 | 9년 전 | 306 | ||
| 5886 | 9년 전 | 245 | ||
| 5885 | 9년 전 | 259 | ||
| 5884 | 9년 전 | 251 | ||
| 5883 | 9년 전 | 266 | ||
| 5882 | 9년 전 | 287 | ||
| 5881 | 9년 전 | 312 | ||
| 5880 | 9년 전 | 228 | ||
| 5879 | 9년 전 | 245 | ||
| 5878 | 9년 전 | 420 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기