I am working on sessions in Django.
By default, django stores sessions in django_session
, I found out there is no way to purge sessions.
Though clearsessions
can be used to delete rows. It is also recommended to run this as a cron job. But doing this means logging out all logged-in users, right?
Is this the right way to do it?
Django 1.6 or Above
python manage.py clearsessions
Django 1.5 or lower
python manage.py cleanup
From Django Shell
django-session-cleanup cronJob
clearing session in logout( based on session key present in request)
The Django documentation states (emphasis from me):
Found this link in Abid A's answer.
The
clearsessions
commandSo it won't log off every user.
As mentioned by Kevin Christopher Henry in a comment and in the other possible duplicate of your question flagged by e4c5.
The newer versions of Django allow: