Javascript & JQuery & CSS > jQuery Cookie(ÄíÅ°) ó¸®
µî·ÏÀÏ : 2017-07-14 16:10
Á¶È¸¼ö : 53,196
jQuery¸¦ ÀÌ¿ëÇÑ ID/PW cookie ÀúÀå ó¸®
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 »èÁ¦