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
Django 1.6 or Above
python manage.py clearsessions
Django 1.5 or lower
python manage.py cleanup
From Django Shell
from django.contrib.sessions.models import Session
Session.objects.all().delete()
django-session-cleanup cronJob
clearing session in logout( based on session key present in request)
from django.contrib.sessions.models import Session
session_key = request.data['sessionKey']
session = Session.objects.get(session_key=session_key)
Session.objects.filter(session_key=session).delete()
Session.objects.all().delete()