I set SESSION_COOKIE_AGE
to some value in my settings.py
and I want to retrieve the time that is left before a session dies by using session.get_expiry_age()
from a view.
However, it seems the returned value is never changing between different calls (at different times): it stays at SESSION_COOKIE_AGE
, meaning the session will never end(?)
Is it a normal behaviour? I would like to notify the user whenever the session is about expire and I don't really see how to do it.
Yes, this is the intended behaviour. See this ticket: https://code.djangoproject.com/ticket/18458
You can use
get_expiry_date()
instead and calculate it from there.