{"id":23601,"library":"django-session-timeout","title":"Django Session Timeout","description":"Middleware for Django that automatically expires user sessions after a configurable period of inactivity. Version 0.1.0 is the latest, with an unpredictable release cadence.","status":"active","version":"0.1.0","language":"python","source_language":"en","source_url":"https://github.com/LabD/django-session-timeout","tags":["django","session","timeout","middleware"],"install":[{"cmd":"pip install django-session-timeout","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core framework requirement","package":"django","optional":false}],"imports":[{"note":"The correct package module is django_session_timeout, not session_timeout.","wrong":"from session_timeout import SessionTimeoutMiddleware","symbol":"SessionTimeoutMiddleware","correct":"from django_session_timeout import SessionTimeoutMiddleware"}],"quickstart":{"code":"from django_session_timeout import SessionTimeoutMiddleware\n\nMIDDLEWARE = [\n    # ...\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'django_session_timeout.middleware.SessionTimeoutMiddleware',\n    # ...\n]\n\n# settings.py\nSESSION_EXPIRE_SECONDS = 3600  # 1 hour\nSESSION_TIMEOUT_REDIRECT = '/login/'  # optional, default '/accounts/login/'","lang":"python","description":"Add SessionTimeoutMiddleware after AuthenticationMiddleware and set SESSION_EXPIRE_SECONDS in settings."},"warnings":[{"fix":"Ensure your MIDDLEWARE list has 'django_session_timeout.middleware.SessionTimeoutMiddleware' after 'django.contrib.sessions.middleware.SessionMiddleware' and 'django.contrib.auth.middleware.AuthenticationMiddleware'.","message":"order of middleware matters: SessionTimeoutMiddleware must be placed after AuthenticationMiddleware and SessionMiddleware.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Explicitly set SESSION_EXPIRE_SECONDS in your Django settings, e.g., SESSION_EXPIRE_SECONDS = 1800.","message":"SESSION_EXPIRE_SECONDS is required, but no default is provided. If not set, all sessions may expire immediately or cause unexpected behavior.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If you want consistent session timeout, set both SESSION_COOKIE_AGE and SESSION_EXPIRE_SECONDS to the same value.","message":"The middleware does not respect Django's SESSION_COOKIE_AGE; it uses its own setting SESSION_EXPIRE_SECONDS.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from django_session_timeout.middleware import SessionTimeoutMiddleware","cause":"Incorrect import path: imported from the top-level package instead of the middleware module.","error":"AttributeError: module 'django_session_timeout' has no attribute 'SessionTimeoutMiddleware'"},{"fix":"Set a valid SECRET_KEY in your Django settings.","cause":"User forgot to set Django's SECRET_KEY when using the middleware.","error":"ImproperlyConfigured: The SECRET_KEY setting must not be empty."},{"fix":"Add SESSION_EXPIRE_SECONDS = <seconds> to your settings.","cause":"The setting SESSION_EXPIRE_SECONDS is not defined in settings.py.","error":"KeyError: 'SESSION_EXPIRE_SECONDS'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}