첨부파일 https://imweb.eond.com/coding/361458

jQuery를 이용한 ID/PW cookie 저장 처리

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var cookieIdKeyStr = "USER_ID";
var cookiePwKeyStr = "USER_PW";
 
$(document).ready(function(){
    <%-- 쿠키값을 읽어와 ID/PW 체크 --%>
    if( $.cookie(cookieIdKeyStr)!="" && $.cookie(cookieIdKeyStr)!=null ) {
        $("#cb_idSave").attr("checked""checked");
        $("#textMemberId").val($.cookie(cookieIdKeyStr));
    }
    if( $.cookie(cookiePwKeyStr)!="" && $.cookie(cookiePwKeyStr)!=null ) {
        $("#cb_pwSave").attr("checked""checked");
        $("#textMemberPw").val($.cookie(cookiePwKeyStr));
    }
});
 
function check() {
    checkSaveIdPw();
}
 
<%-- ID/PW 저장 체크 --%>
function checkSaveIdPw() {
    var checkStatus = $("#cb_idSave").is(":checked");
    if( checkStatus ) {
        $.cookie(cookieIdKeyStr, $("#mnMemberCode").val(), { expires: 30 });        
    } else {
        $.cookie(cookieIdKeyStr, null);
    }
    
    checkStatus = $("#cb_pwSave").is(":checked");
    if( checkStatus ) {
        $.cookie(cookiePwKeyStr, $("#mnMemberPwd").val(), { expires: 30 });        
    } else {
        $.cookie(cookiePwKeyStr, null);
    }
}

 

 

jQuery  cookie 사용법 

$.cookie('the_cookie'); //cookie취득  
$.cookie('the_cookie', 'the_value'); //cookie를 셋팅
$.cookie('the_cookie', 'the_value', { expires: 7 }); //쿠키의 유효기간을 7일간으로 지정  
$.cookie('the_cookie', '', { expires: -1 }); //cookie 삭제
$.cookie('the_cookie', null); //cookie 삭제

 

https://github.com/carhartl/jquery-cookie // jQuery 쿠키 js 다운로드 및 참조 

 

참고 : http://blog.naver.com/PostView.nhn?blogId=lazyker&logNo=110132802552

 

코멘트 0
접기/펴기 | 댓글 새로고침
 
 
Total 62 articles in 4 / 4 pages
번호 제목 제목 날짜날짜
공지 코딩 배울 수 있는 사이트 모음(HTML/CSS/JS/IMG/PHP) 2018/01/03
공지 jQuery를 배울수 있는 동네들입니다. 2013/08/09
공지 관련 링크 [1] 2010/05/23
2 [Script] 폼 크기 자동으로 늘였다 줄였다.. 2003/09/23
1 [Script] 글자 크기 바꾸기 2003/07/23

해시태그 디렉터리

오늘의 핫게시물