2👍
You have to use the database-backed session. From the doc:
you need to add ‘django.contrib.sessions’ to your INSTALLED_APPS
setting.
Once you have configured your installation, run manage.py migrate to install the single database table that stores session data.
Then you have to ensure that the session.flush()
is not called in the logout/login process, witch implies avoid using the django.contrib.auth.logout()
witch will call session.flush(), it is also called in django.contrib.login()
. login and logout
the user yourself to avoid losing the session data. source for login/logout.
1👍
The session is flushed at login/logout, as a security measure. If you want to retain some variables, you can use the solution at:
https://stackoverflow.com/a/41849076/146289
It basically involves backing up old values, and then restoring them in the new session.
- [Django]-What happens during AWS Elastic Beanstalk 504 Gateway Timeout
- [Django]-How to show specific field only to the user profile owner in graphene-django?
- [Django]-Django migrations: how to generate database from current state of the models (good old syncdb –all)
- [Django]-Prevent skip in docker-compose