Remember Me checkbox

Good morning everyone.
I’m just starting to learn Django, so forgive me if my question seems trivial.

I’ve created a login page in Django, and so far so good.
The problem is that I can’t in any way implement a remember me checkbox.

Could you help me please?

Thank you all.

What, specifically and completely, do you want this “Remember me” checkbox to do?
(What effect do you want it to have with your users?)

Hi KenWhitesell, thank you for your response.
I just want that the user doesn’t have to rewrite every time the username and the password.
So if the checkbox “Rember Me” is checked, the next time that the user open the website, the username and the password are already compiled.
I know that there is the possibility to do that by normal browsers, but i really want to add this feature on my website.
I know that the security of the login decrease, with the options of remember me, but i don’t necessarily have a so strong security for my particular application.

Thank you again.
Sorry for the bad English.

This is basically done by creating a non-expiring (or long-duration) cookie that is sent to the browser. That cookie would generally contain either a reference to login information in the database, or an encrypted version of the username and password.

What you do with that information after that is up to you.

For example, you could automatically log the person on when they first go to your site. (The cookie gets sent to the server, it find the data and programmatically logs the person in.) Or, you could prefill the login form with that data to where they still need to click the login button.

Good Evening KenWhitesell.
Thank you really much.
Ok i understand (Good idea).
But, please, could you just see a example of code, so may i have the ability to learn from your example, and turn my login form working.

I know that this question could lead you to think that I don’t want to commit myself, and that I want easy answers right away.
But it’s not like that, I’ve tried and tried but I really haven’t been able to get to a working draft of code.

For this I thank you very much, together with all those of the forum who are available to help a desperate person like me.

Unfortunately, I don’t have any code to share - I’ve never done anything like this. My knowledge in this area is purely academic.

I think this page may help How to use sessions | Django documentation | Django

1 Like