title: Django if user.is_authenticated not working
body: <p>I am just trying to run a simple <code>{% if user.is_authenticated %}</code> . But it always return <code>False</code>.</p>
  
  <p>Here are my all the files.</p>
  
  <p><code>views.py</code></p>
  
  <pre><code>from django.shortcuts import render_to_response, redirect
  from django.core.urlresolvers import reverse
  from django.template import RequestContext
  from django.contrib.auth.models import User
  from django.http import HttpResponse
  from django.contrib.auth.hashers import *
  from forms import UserLoginForm
  from models import UserLogin
  
  def index(request):
      return render_to_response('index.html', context_instance = RequestContext(request))
  
  def login(request):
      if request.method == 'POST':
          form = UserLoginForm(request.POST or None)
          if form.is_valid():
              email_from_form = form.cleaned_data['email']
              password_from_form = form.cleaned_data['password']
              users = User.objects.filter(email = email_from_form)
  
              for j in users:
                  if j.email == email_from_form:
                      pass_match = check_password(password_from_form, j.password)
                      if pass_match:
                          return redirect(reverse('profile'), context_instance = RequestContext(request))
                      else:
                          return HttpResponse('Entered password did not match')
                  else:
                      return HttpResponse('Entered email does not exist')
          else:
              return HttpResponse(form.errors)
      else:
          form = UserLoginForm()
  
      return render_to_response('login.html', {'form':form}, context_instance = RequestContext(request))
  
  
  def profile(request):
  
      return render_to_response('profile.html', context_instance = RequestContext(request))
  </code></pre>
  
  <p><code>forms.py</code></p>
  
  <pre><code>from django import forms
  
  class UserLoginForm(forms.Form):
      email = forms.EmailField(max_length = 100)
      password = forms.CharField(max_length = 100)
  </code></pre>
  
  <p><code>models.py</code></p>
  
  <pre><code>from django.db import models
  
  class UserLogin(models.Model):
      email = models.EmailField(max_length = 100)
      password = models.CharField(max_length = 100)
  
      def __unicode__(self):
          return self.email
  </code></pre>
  
  <p><code>profile.html</code></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;profile&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      {% if user.is_authenticated %}
          Welcome user, you are loged in..
      {% else %}
          You are not logged in
      {% endif %}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><code>login.html</code></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="{% url login %}" method="POST"&gt;
          {% csrf_token %}
          {{ form.as_p }}
          &lt;input type="submit" id="submit" name="submit" value="Login" /&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>It always returning <code>You are not logged in</code></strong></p>
  
  <p>I am new to django and I dont understand this why it is like this.</p>