I am attempting to use django for my website. i implemented login using this code:7
user_django = authenticate(username=email, password=passw)
login(request, user_django)
which using django rest framework is working. But when i use it with an ajax request i think its not storing cookies. i am also using a django function to check if the user is logged in:
if request.user.is_authenticated():
return Response('1')
else:
return Response('0')
but it always return 0. Do i have to do anything special on the client side to store the login information?
my javascript login:
function userLogin(){
var user_email = $('#login_user_email').val();
var user_pwd = $('#login_user_pwd').val();
var data = {email:user_email, password:user_pwd};
$.ajax(prefix+ 'userLogin/', {
success: function(output, status, xhr){
$('#login_btn').click();
},
data: data,
type: 'POST'
});
}