“Django Connection Session Horário” Respostas de código

Django Connection Session Horário

I use Django 2.1.7 and the easiest way to expire django session is:

first you need to install django-session-timeout with command:

pip install django-session-timeout

then you need to update your SessionTimeoutMiddleware in settings.py

MIDDLEWARE_CLASSES = [
     ...
    'django.contrib.sessions.middleware.SessionMiddleware',
 #add below middleware 
    'django_session_timeout.middleware.SessionTimeoutMiddleware',
     ...
]

at last you need to add SESSION_EXPIRE_SECONDS at the end of settings.py:

SESSION_EXPIRE_SECONDS = 300  # 300 seconds = 5 minutes

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
BlueMoon

Django Connection Session Horário

There are two parameters to expire sessions, SESSION_EXPIRE_AT_BROWSER_CLOSE and SESSION_COOKIE_AGE. If you want to expire in 5 minutes yours settings should like as:

SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_COOKIE_AGE = 5 * 60 #
BlueMoon

Respostas semelhantes a “Django Connection Session Horário”

Perguntas semelhantes a “Django Connection Session Horário”

Mais respostas relacionadas para “Django Connection Session Horário” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código