0

Hi i have added a remember me checkbox in login template in the following way. The user will be redirected to the login template after clicking on signout. My requirement is when user logs in with remember me checkbox checked he should return to login page with checkbox checked, similarly when user logs in with remember me checkbox unchecked he should return to login page with checkbox uncheked. Please help me how to do this?

<div class="remember-me-div">
    <label class="checkbox">
        <input type="checkbox" name="remember-me">
        <span class="rememberme-txt">Remember me</span>
    </label>
</div>
  • You can store the state of the checkbox in a cookie: https://docs.djangoproject.com/en/1.7/ref/request-response/#django.http.HttpRequest.COOKIES – Selcuk Feb 27 '15 at 10:18

1 Answers1

0

Add it COOKIES and then use that to populate the field.

if request.COOKIES.has_key( 'rememberme' ):
    value = request.COOKIES[ 'rememberme' ]

Use the helper from here to set the cookie https://stackoverflow.com/a/1623910/1130446

Community
  • 1
  • 1
Rodney Hawkins
  • 404
  • 3
  • 7