How to set the length and age of a Django auth.login session?

I have a Django application deployed to the Google App Engine that is registering its users prematurely. But the browser window / tab does not close. In settings.py, I have this code:

SESSION_COOKIE_AGE = 365 * 24 * 60 * 60 SESSION_EXPIRE_AT_BROWSER_CLOSE = False 

I also tried using this code right after calling auth.login() :

 request.session.set_expiry(30*24*60*60) 

Is there a way that I can allow the auth.login session length to be much longer, say, a year?

+4
source share
1 answer

If you use the cache interface for a session, it is possible that the session data is deleted from the cache, which for the user will look like he / she is logged out. Memcache can / delete data in some cases, i.e. Make way for your new data.

To narrow down the problem, I recommend:

  • checking if the session is really deleted from the cache
  • Switching to another session to see if the problem goes away.
+3
source

Source: https://habr.com/ru/post/1397420/


All Articles