javascript

  • 쿠키 저장(로그인)
$.ajax({
	type: "POST",
 	url: "/sign_in",
	data: {
    	username_give: username,
        password_give: password
    },
    success: function (response) {
    	if (response['result'] == 'success') {
            $.cookie('mytoken', response['token'], {path: '/'}); //쿠키에 저장
            window.location.replace("/")
        } else {
            alert(response['msg'])
        }
    }
 });

 

  • 로그아웃(로그아웃)
<script>
	function sign_out() {
        $.removeCookie('mytoken', {path: '/'});
        alert('로그아웃!')
        window.location.href = "/login"
	}
</script>

'프로그래밍 > Javascript & jQuery' 카테고리의 다른 글

jQuery - toggle 토글  (0) 2022.05.03
jQuery (val, hide, show, split, includes, append, empty)  (0) 2022.03.30
Javascript 기초  (0) 2022.03.23

+ Recent posts