--- id: django-session-timeout version: "0.1.0" license: MIT license_treatment: permissive maintenance: active --- # django-session-timeout — Middleware to expire sessions after specific amount of time License: permissive · Maintenance: active · Downloads: 77.4K/mo ## What it is and what it does django-session-timeout is a Django middleware that enforces automatic session expiration based on time. It adds timestamp tracking to sessions and can expire them either after a fixed duration from session creation or after a period of user inactivity. The middleware integrates into Django's standard session framework and requires minimal configuration—just adding it to MIDDLEWARE_CLASSES and setting SESSION_EXPIRE_SECONDS. The package supports flexible expiration strategies: you can track inactivity with optional grace-period grouping to reduce database writes, and redirect expired sessions to a custom URL. It depends on Django and six, making it lightweight and compatible with existing Django projects. Use it for: - Enforce security policies requiring user sessions to expire after a fixed time period in web applications. - Log out inactive users automatically to reduce unauthorized access risk in shared or public-facing systems. - Implement inactivity-based timeouts that reset on user activity to balance security with user experience. - Redirect expired sessions to a login page or custom endpoint for graceful session termination. - Group activity timestamps by different periods to reduce database load while tracking user inactivity. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds automatic session expiration to Django applications, allowing sessions to expire after a fixed duration or period of inactivity. Yes. The package is stable, actively maintained, has low install friction, carries no known vulnerabilities, and solves a common Django security need. MIT licensing imposes no restrictions. Install it if you need automatic session expiration; the configuration is straightforward and the middleware integrates cleanly into Django's standard session handling. ## Install pip install django-session-timeout uv add django-session-timeout poetry add django-session-timeout ## Installing django-session-timeout Before you install: Low friction installation with only 2 runtime dependencies. Actively maintained with recent commits; last update was 2026-04-28. Stable production release status. License in practice: MIT license is permissive, allowing commercial and private use with minimal restrictions. Quickstart: pip install django-session-timeout # In settings.py, add to MIDDLEWARE_CLASSES: 'django_session_timeout.middleware.SessionTimeoutMiddleware', # Set expiration time: SESSION_EXPIRE_SECONDS = 3600 Requires Django and six as runtime dependencies; must be added to Django's MIDDLEWARE_CLASSES configuration. Verify before relying: - Whether the package supports Django versions released after 3.0 (classifiers list only through 3.0) - Whether Python 3.8+ is supported (classifiers only list through 3.7) ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 77.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django session expiration, session timeout middleware, django user session timeout, expire inactive sessions, django session management, session inactivity timeout, django middleware session, django-middleware, session-management, security [View on SkillFed](https://skillfed.io/packages/django-session-timeout) · [View on PyPI](https://pypi.org/project/django-session-timeout/)