django-redis icon indicating copy to clipboard operation
django-redis copied to clipboard

Session expiration time

Open rpop0 opened this issue 3 years ago • 6 comments

Hi,

I started using this for caching sessions in my project, but an issue I have is that they expire a bit too quickly and the users constantly have to log back in. Any way to set the expiration time for them?

rpop0 avatar Apr 10 '22 10:04 rpop0

SESSION_COOKIE_AGE? https://docs.djangoproject.com/en/4.0/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions

millerthegorilla avatar Apr 10 '22 13:04 millerthegorilla

It is set to the default 2 weeks but it expires multiple times per day.

rpop0 avatar Apr 10 '22 14:04 rpop0

It seems very strange to me, so I advise to take a look at expiration time using TTL command or trying django.contrib.sessions.backends.cache_db or django.contrib.sessions.backends.db.

django-redis does not implement anything on top of django's session backends so this behaviour is implemented in django itself.

Did you add any other SESSION_* variable in settings?

please paste here any settings for cache and session to make it easy to understand the problem

WisdomPill avatar Apr 10 '22 14:04 WisdomPill

@rpop0 any news about this? otherwise in a week or so I will close this

WisdomPill avatar Apr 18 '22 06:04 WisdomPill

No news about this, everything seems to be set correctly, but the sessions still expire prematurely.

rpop0 avatar Apr 18 '22 19:04 rpop0

Have you made the tests I suggested? Can you share cache related settings? Can you reproduce the issue elsewhere (demo application)?

WisdomPill avatar Apr 18 '22 19:04 WisdomPill