Answer the question
In order to leave comments, you need to log in
How to set session lifetime in Django?
In addition to the main login method (through forms with csrf verification), I make an additional view for logging in mobile devices.
Mobile devices will log in through a simple, login(request, user), and I will give the client a request.session.session_key (this is the session_id of the session).
The thing is that I would like to set the lifetime of this (namely this) session equal to, for example, five years.
Digging through the documentation, I found this setting:
SESSION_COOKIE_AGE - Session cookie age in seconds.
Default: 1209600 (2 weeks in seconds)
Answer the question
In order to leave comments, you need to log in
from django.contrib.sessions.models import Session
Session.objects.get(session_key=request.session.session_key).expire_date
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question