On Tue, Oct 22, 2013 at 12:53 PM, Praveen Madhavan
<
prave...@gmail.com> wrote:
> Hello All,
>
> I am trying custom authentication with django, I wrote a class and
> filled it with the methods authenticate and get_user, I also added this
> authentication to the AUTHENTICATION_BACKENDS in settings.py file.
>
> I have called my custom authenticate method and followed it up with
> login in my view.
Show us this view. You should not be calling a "custom authenticate
method", you should be using login() and authenticate() from
django.contrib.auth. If you are not, then this explains why on
subsequent views you are not logged in.
>
> Everything seems to work fine, is_authenticated returns true for the
> user after login, but the subsequent requests have request.user as
> anonymous, unable to figure out the reason, require your help
The other cause of login failing is if your browser does not send the
session cookie back to the server. This would happen if you have
configured django to send cookies with a different host than the pages
are served from. Use chrome inspector or firefox or any other tool you
fancy to determine if this is the case.
The easiest way to see is to look at the session cookie sent with the
pre-login page response, and the session cookie sent with the
post-login page response, do they have different ids?
Cheers
Tom