첨부파일 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 3 / 4 pages
번호 제목 제목 날짜날짜
공지 코딩 배울 수 있는 사이트 모음(HTML/CSS/JS/IMG/PHP) 2018/01/03
공지 jQuery를 배울수 있는 동네들입니다. 2013/08/09
공지 관련 링크 [1] 2010/05/23
22 [Script] 레이어를 이용한 서브 메뉴 2007/09/10
21 [Script] 스위칭 탭 2007/08/19
20 [Script] 최소/최대화 버튼 없는 군더더기 없는 새창 띄우기 2007/04/22
19 [Script] PNG 알파 필터 사용하기 [1] 2007/04/21
18 [Script] DIV 레이어 토글 [1] 2007/04/21
17 [Script] Iframe 크기 내용에 따라 자동조절하기 (by konahn) [1] 2007/04/17
16 [Script] 한 번의 클릭으로 두 개의 아이프레임 제어하기 2007/04/16
15 [Script] iframe 자동 리사이즈 [6] 2007/04/16
14 [Script] 클릭하면 닫히는 창 2005/04/28
13 [Script] 마우스 올렸을 때 바뀌는 커서 (by kiwha) 2004/12/14
12 [Script] ~한지 **일 되었습니다 (by kihwa) 2004/12/14
11 [Script] 클릭하면 경고창 뜨는 스크립트 [1] 2004/12/14
10 [Script] 부모창 닫고 새창 띄우기 (by zero) 2004/05/13
9 [Script] 새창 띄우고 자동 리사이징 (by Aquatype) 2004/05/06
8 [Script] 접속 시 자동으로 새창 띄우고, 띄워져 있으면 새로고침해도 안 띄우기 (by Aquatype) 2004/05/06
7 [Script] 링크 자동으로 onfocus="blur()" 붙이기 (by 후니) [2] 2004/05/05
6 [Script] 링크 자동으로 onfocus="blur()" 붙이기 (by 멋진돌) [1] 2004/05/05
5 [Script] 링크 자동으로 onfocus="blur()" 붙이기 (by 라지엘) 2004/05/05
4 [Script] body에 2개 이상의 인자 띄우기 2004/04/27
3 [Script] 비밀글 체크박스를 이미지로 바꾸기 2003/10/26

해시태그 디렉터리

오늘의 핫게시물