생성
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6027 | 9년 전 | 311 | ||
| 6026 | 9년 전 | 271 | ||
| 6025 | 9년 전 | 251 | ||
| 6024 | 9년 전 | 410 | ||
| 6023 | 9년 전 | 288 | ||
| 6022 | 9년 전 | 286 | ||
| 6021 | 9년 전 | 282 | ||
| 6020 | 9년 전 | 254 | ||
| 6019 | 9년 전 | 226 | ||
| 6018 | 9년 전 | 209 | ||
| 6017 | 9년 전 | 247 | ||
| 6016 | 9년 전 | 238 | ||
| 6015 | 9년 전 | 200 | ||
| 6014 | 9년 전 | 168 | ||
| 6013 | 9년 전 | 269 | ||
| 6012 | 9년 전 | 210 | ||
| 6011 | 9년 전 | 225 | ||
| 6010 | 9년 전 | 221 | ||
| 6009 | 9년 전 | 311 | ||
| 6008 | 9년 전 | 201 | ||
| 6007 | 9년 전 | 205 | ||
| 6006 | 9년 전 | 255 | ||
| 6005 | 9년 전 | 223 | ||
| 6004 | 9년 전 | 314 | ||
| 6003 | 9년 전 | 273 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기