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
url(r'^login/$','django.contrib.auth.views.login', {'template_name': 'authentication/login.html'}, name='login'),
The checkbox is implemented in my login.html as:
<label><input name="remember_me" type="checkbox">Keep me logged in</label>
but I am not sure how to pass that information through the AuthenticationForm to the django.contrib.auth.views.login
Currently, if the user logs "remember me" box unchecked, the cookie age is defined in settings.py
SESSION_COOKIE_AGE = 360
I found couple of similar questions but I don't think this should require a separate app to be installed. The below snippet (http://djangosnippets.org/snippets/1881/) seemed promising but I have coded python and Django only for couple of months and I wasn't able to get it working:
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)