django signals are very convenient:
# this is in a models.py file from django.db.models.signals import pre_delete from django.contrib.sessions.models import Session def sessionend_handler(sender, **kwargs):
you will need to delete the reguraly session, as they can remain in the database if the user does not click on "logout", which is most often found. just add this to cron:
*/5 * * * * djangouser /usr/bin/python2.5 /home/project/manage.py cleanup
In addition, I usually add this to my manage.py file for the convenience of setting up .py path find:
import sys import os BASE_DIR = os.path.split(os.path.abspath(__file__))[0] sys.path.insert(0, BASE_DIR)
SESSION_EXPIRE_AT_BROWSER_CLOSE works, but only affects client cookies, not IMHO server asset sessions.
source share