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.0.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.0-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.0.tar.gz.

File metadata

File hashes

Hashes for django_session_timeout_2025-0.1.0.tar.gz
Algorithm Hash digest
SHA256 725943c12f71265a959ec484f2e3205db0137aad4431ca95d78a378e50d17398
MD5 5f9adcd72c930a86d6cc01ad7ed165e1
BLAKE2b-256 5b5ccc6c23bb1b2711beeecb451655e8a1fdb702cfdb916d1bc960b8f01c1d8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_session_timeout_2025-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 13ac04fe8d1c4d202bed18eb6711f0ed6707fef6647ee6fdacc55a3dca93b24a
MD5 28fdc47aa95b4d28b7427fa806c4acc8
BLAKE2b-256 5c4347fd400cf12b0daf63d4f3f23156d6dd3ce6da5a608c21b1cc803f0c0ce1

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