Generally, the system requires that the simplest logon feature always has a password-remembering function. Websites like Douban automatically remember the password and do not have a chance for users to choose from. However, the loss of its password will not cause too much loss, and I don't know if it uses the Django framework, so it's hard to say. However, if he wants to make online sales in the future, this problem must be solved.
In Django's implementation, a configuration in the configuration file determines whether to enable the Remember password function, and is enabled by default. If this configuration is changed, it becomes the cookie of the browser lifecycle, however, there is no way to remember the password. You can only select one of them.
Later I considered an article on the Internet.ArticleUnder the Django directory, contrib/sessions/has a middleware. py, which is the implementation process of the session. In its processresponse, there is a judgment. If this configuration is the browser lifecycle, a cookie with expired as none will be written to the client. Otherwise, a cookie with an expiration time of two weeks will be written.
To simplify the modification process (because it will soon be available in Version 1.0, I am afraid I will change it again), I made a lazy modification: take the value of the 'issaved' variable in the session directly here. If it is true, the two-week cookie is also saved. Otherwise, the default value is used. Then, when the user logs on, if the user selects this box, the variable "true" will be added to the session. Everything is OK, and only three lines need to be changed.Code. But the trouble is that every time you update Django, You have to modify it, and every time you migrate the server environment. If you forget it once, you will have to remember that the password will fail.