title: Django "Remember Me" with built-in login view and authentication form
body: <p>How can I reuse the original admin login() and AuthenticationForm to set longer cookie length for users with "remember me" option checked at login page? I am currently using the built-in login through urls.py</p>
  
  <pre><code>url(r'^login/$','django.contrib.auth.views.login', {'template_name': 'authentication/login.html'}, name='login'),
  </code></pre>
  
  <p>The checkbox is implemented in my login.html as:</p>
  
  <pre><code>&lt;label&gt;&lt;input name="remember_me" type="checkbox"&gt;Keep me logged in&lt;/label&gt;
  </code></pre>
  
  <p>but I am not sure how to pass that information through the AuthenticationForm to the django.contrib.auth.views.login</p>
  
  <p>Currently, if the user logs "remember me" box unchecked, the cookie age is defined in settings.py</p>
  
  <pre><code>SESSION_COOKIE_AGE = 360
  </code></pre>
  
  <p>I found couple of similar questions but I don't think this should require a separate app to be installed. The below snippet (<a href="http://djangosnippets.org/snippets/1881/" rel="noreferrer">http://djangosnippets.org/snippets/1881/</a>) seemed promising but I have coded python and Django only for couple of months and I wasn't able to get it working:</p>
  
  <pre><code>def login(request, *args, **kwargs):
      if request.method == 'POST':
          if not request.POST.get('remember_me', None):
              request.session.set_expiry(0)
      return auth_views.login(request, *args, **kwargs)
  </code></pre>