“Waktu Sesi Koneksi Django” Kode Jawaban

Waktu Sesi Koneksi Django

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

Waktu Sesi Koneksi Django

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

Jawaban yang mirip dengan “Waktu Sesi Koneksi Django”

Pertanyaan yang mirip dengan “Waktu Sesi Koneksi Django”

Lebih banyak jawaban terkait untuk “Waktu Sesi Koneksi Django” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya