Hello ,

I am new to Django and trying to handle signin/ signout request
according to following documentation

http://docs.djangoproject.com/en/1.3/topics/auth/#how-to-log-a-user-in


I am using fiddler tool on windows for testing the get/post requests


Problem :
when I make a post request with username and password  to
http://localhost:8000/signin/
I am getting a row in mysql django_session table.

when I make a POST request to http://localhost:8000/signout/
I am again getting a row in mysql django_session table. where i
suppose it should  delete my earlier row in database.

my code is as following .


@csrf_exempt
def signin(request):

    response = Response()
    # Only POST requests are authorized
    if request.method == 'POST':
        try:
            username = request.POST['username']
            password = request.POST['password']
        except MultiValueDictKeyError:
            response.set_error('fields1',
Strings.error_message['ERROR_INFORMATION_MISSING'])
        else:
            user = authenticate(username=username,
password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                else:
                    response.set_error('user_not_active',
Strings.error_message['ERROR_USER_NOT_ACTIVE'])
            else:
                response.set_error('no_user',
Strings.error_message['ERROR_USER_DOES_NOT_EXIST'])
    else:
        response.set_error_POST_required()

    return HttpResponse(simplejson.dumps(response.content),
mimetype='application/javascript')


@csrf_exempt
def signout(request):
    """
    Simply logs out
    """
    response = Response()
    logout(request)
    return HttpResponse(simplejson.dumps(response.content),
mimetype='application/javascript')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to