I have the following requirements:
- Users must be able to see (and log out) their other sessions.
- Sessions must expire BOTH at browser close and after a perioid of inactivity.
default
database can not be used to store sessions.
My current approach would be to set SESSION_EXPIRE_AT_BROWSER_CLOSE
and add a middleware class that checks the last_activity / and updates the timestamp (or calls logout()
if the session has expired) and also run a periodic cleanup on inactive sessions.
However, I couldn't find a way to access the non-database backed sessions outside a request (- or a way to access anything except the current session inside a request)
Furthermore, I couldn't find any documentation how to store the django_session
table to another database.
I'm currently using cache backed sessions using a file based cache, but that can be changed - the only requirement is not to store the sessions in the default
database.