Skip to main content

Middleware to expire sessions after specific amount of time

Project description

django-session-timeout-2025

Add timestamp to sessions to expire them independently

Installation

pip install django-session-timeout-2025

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 activity 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.

Source Distribution

django_session_timeout_2025-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_session_timeout_2025-0.1.1-py2.py3-none-any.whl (4.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_session_timeout_2025-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django_session_timeout_2025-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2fb30bb8eed559b0d20a0e04fc44844b8fb3fe7d38e9a5f2e928e2a5ac691710
MD5 54a41fddc94a0e79ff6f934e1d4e1f1e
BLAKE2b-256 9ae434063d95d77073f8df89de69ace8c60e2ff2f19cacd81b7a9605f6edb5e8

See more details on using hashes here.

File details

Details for the file django_session_timeout_2025-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_session_timeout_2025-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5b5e1c9e4258cf40d6de008a801f90fc3d77d3440002354648626fcb88f92d0c
MD5 97b35db9af1cdf121b9ff58839145bcc
BLAKE2b-256 daf50df11bad9f903ee026c90cc291d26e72602e2a9b7b7501cb4fe5a9c6f111

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page