Skip to content

About

Add timestamp to sessions to expire them

Resources

Stars

38 stars

Watchers

6 watching

Forks

Repository files navigation

django-session-timeout

PyPI tests readthedocs

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 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/'

Releasing

Changes are tracked with changie. Add a changelog entry to every pull request with a user-facing change:

changie new

When entries are merged to the default branch, a release pull request is opened (or updated) automatically. Merging that pull request tags the release, creates the GitHub release and publishes the package to PyPI.

About

Add timestamp to sessions to expire them

Resources

Stars

38 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages