쿠키 설정 12시간

쿠키 설정 12시간

QA

쿠키 설정 12시간

본문


   // 쿠키 가져오기
   function getCookie( name ) {
      var nameOfCookie = name + "=";
      var x = 0;
      while ( x <= document.cookie.length )
      {
       var y = (x+nameOfCookie.length);
       if ( document.cookie.substring( x, y ) == nameOfCookie ) {
        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
         endOfCookie = document.cookie.length;
        return unescape( document.cookie.substring( y, endOfCookie ) );
       }
       x = document.cookie.indexOf( " ", x ) + 1;
       if ( x == 0 )
        break;
      }
      return "";
   }
   // 24시간 기준 쿠키 설정하기
   // expiredays 후의 클릭한 시간까지 쿠키 설정
   function setCookie( name, value, expiredays ) {
      var todayDate = new Date();
      todayDate.setDate( todayDate.getDate() + expiredays );
      document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
   }

 

 

위 팝업용 코드를 가지고 사이드에 광고 배너 같은 것을 볼 수 없도록 응용을 했습니다.

1일(24시간) 동안 보지 않는 것을 12시간으로 수정하려면 뭘 고쳐야 하나요?

답변 부탁드립니다!!

이 질문에 댓글 쓰기 :

답변 2

https://stackoverflow.com/questions/13154552/javascript-set-cookie-with-expire-time 

참고하셔서 

 

var time = now.getTime();

var expireTime = time + 1000*60*60*12 ; 

이런 식으로 day 관련 부분을 바꿔주셔야 할 것같아요 

답변을 작성하시기 전에 로그인 해주세요.
전체 123,512 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT