-
스크립트 로그인 쿠키프로그래밍/자바 2018. 8. 27. 14:27
// 쿠키 생성 & 삭제
function setCookie(cName, cValue, cDay){
var expire = new Date();
expire.setDate(expire.getDate() + cDay);
cookies = cName + '=' + escape(cValue) + '; path=/ ';
if(typeof cDay != 'undefined') cookies += ';expires=' + expire.toGMTString() + ';';
document.cookie = cookies;
}
// 쿠키 가져오기
function getCookie(cName) {
cName = cName + '=';
var cookieData = document.cookie;
var start = cookieData.indexOf(cName);
var cValue = '';
if(start != -1){
start += cName.length;
var end = cookieData.indexOf(';', start);
if(end == -1)end = cookieData.length;
cValue = cookieData.substring(start, end);
}
return unescape(cValue);
}$(document).ready(function() {
//쿠키가 있으면
if(getCookie("usrid") != ""){ /* typeof getCookie("usrid") !="undefined" */
$("#usrid").val(getCookie("usrid"));
$("input:checkbox[id='chkBoxId']").prop("checked", true);
}else if(getCookie("usrid") == ""){
$("input:checkbox[id='chkBoxId']").prop("checked", false);
}
$("#btnLogin").on("click", function() {
login();
});
$("#passwd").keyup(function(e){
if(e.keyCode == 13)
login();
});
});'프로그래밍 > 자바' 카테고리의 다른 글
highcharts legend 겹칠때 (0) 2018.09.07 script에서 toggle 사용 (0) 2018.08.27 jsp에서 넘기는 파라미터가 한글일 때 서블릿에서 깨지는 경우 (0) 2018.08.27 svn checkout Maven 라이브러리 오류 해결방법 (0) 2018.08.27 이클립스 프로젝트명 변경시 해야할 것 (0) 2018.08.27