Skip to main content

A simple Django middleware to refresh user sessions periodically to prevent timeout during active use

Project description

django-session-refresh

A simple Django middleware to refresh user sessions periodically (24h by default) to prevent timeout during user activity.

This middleware updates a timestamp in the session data at specified intervals, effectively extending the session's lifetime as long as the user is active.

Installation

  1. Run pip install django-session-refresh
  2. Add session_refresh.middleware.SessionRefreshMiddleware settings.py ass bellow
MIDDLEWARE = [
    ...
    'django.contrib.sessions.middleware.SessionMiddleware',  # Django default SessionMiddleware
    'session_refresh.middleware.SessionRefreshMiddleware',   # django-session-refresh
    ...
]

Configuration (optional)

The settings bellow are optional and if not defined in settings.py the default values will be used.

# The interval in seconds to refresh the session
SESSION_REFRESH_INTERVAL = 86400  # 24 hours
# The name of the session key to store the last refresh timestamp
SESSION_REFRESH_KEY = 'last_session_refresh'
# Skips session refresh for admin users
SESSION_REFRESH_SKIP_ADMIN_USERS = True
# Skips session refresh for static and media file requests
SESSION_REFRESH_SKIP_STATIC_AND_MEDIA = True
# Skips session refresh for unauthenticated users
SESSION_REFRESH_SKIP_UNAUTHENTICATED_USERS = True

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_refresh-0.1.0.tar.gz (6.8 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_refresh-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file django_session_refresh-0.1.0.tar.gz.

File metadata

  • Download URL: django_session_refresh-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_session_refresh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c20e593e1160d0b109321a28dc54ade5731e2ef3e33bdcce941d5302fc178f1
MD5 69e35a986c5be3cb99dcf62bafcc1016
BLAKE2b-256 8f395d7c92c73a6afbb0cb2f3283f99496c916612f1d3b266e40c22fcd704f99

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_session_refresh-0.1.0.tar.gz:

Publisher: publish.yml on amilnosredna/django-session-refresh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_session_refresh-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_session_refresh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24b9264718e9bd174aa2a677e98d3b25b95ca8e9f895c19a480cb04577498c11
MD5 cb477b881602df4bf7c99de706fc697a
BLAKE2b-256 99b7dd0888568e3b632cbc162528eb64908c54f98bea9be3a24d92ba6c797ccb

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_session_refresh-0.1.0-py3-none-any.whl:

Publisher: publish.yml on amilnosredna/django-session-refresh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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