Skip to content

davisnando/django-session-timeout

 
 

Repository files navigation

https://dev.azure.com/lab-digital-opensource/django-session-timeout/_apis/build/status/labd.django-session-timeout?branchName=master http://codecov.io/github/LabD/django-session-timeout/coverage.svg?branch=master Documentation Status https://img.shields.io/github/stars/labd/django-session-timeout.svg?style=social&logo=github

django-session-timeout

Add timestamp to sessions to expire them independently

Installation

pip install django-session-timeout

Usage

Update your settings to add the SessionTimeoutMiddleware:

MIDDLEWARE_CLASSES = [
    # ...
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django_session_timeout.middleware.SessionTimeoutMiddleware',
    # ...
]

And also add the SESSION_EXPIRE_SECONDS:

SESSION_EXPIRE_SECONDS = 3600  # 1 hour

By default, the session will expire X seconds after the start of the session. To expire the session X seconds after the last activity, use the following setting:

SESSION_EXPIRE_AFTER_LAST_ACTIVITY = True

By default, last activiy will be grouped per second. To group by different period use the following setting:

SESSION_EXPIRE_AFTER_LAST_ACTIVITY_GRACE_PERIOD = 60 # group by minute

About

Add timestamp to sessions to expire them

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 93.7%
  • Makefile 6.3%