Skip to main content

Middleware to expire sessions after specific amount of time

Project description

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

To redirect to a custom URL define the following setting:

SESSION_TIMEOUT_REDIRECT = 'your_redirect_url_here/'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-session-timeout, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size django_session_timeout-0.1.0-py2.py3-none-any.whl (3.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-session-timeout-0.1.0.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page