Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django connexion session time

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
Comment

django connexion session time

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 #
Comment

PREVIOUS NEXT
Code Example
Python :: csv to pdf python 
Python :: text to png python 
Python :: python 3.4 release date 
Python :: python main template 
Python :: python builtwith 
Python :: how to check if string ends with specific characters in python 
Python :: python random distribution 
Python :: optimize python code 
Python :: how to make a operating system in python 
Python :: sublime autocomplete python 
Python :: number pattern program in python using for loop 
Python :: duck typing in python 
Python :: value_counts sort by index 
Python :: simple plt plot 
Python :: pandas merge_asof direction 
Python :: File "main.py", line 21 print("total harga:idr", bakso bulat +str Minuman Drink): ^ SyntaxError: invalid syntax 
Python :: Computation failed in `stat_flow()`: 
Python :: wxpython menu callback stackoverflow 
Python :: how to add twoo segmen time series in a single plot 
Python :: run shell script to yaml file 
Shell :: remove nginx from ubuntu 
Shell :: react-scripts is not recognized as an internal command windows 
Shell :: grep ip address 
Shell :: install git-lfs ubuntu 18.04 
Shell :: install ext-dom linux 
Shell :: git match remote master 
Shell :: ubuntu tweak 
Shell :: docker stop all 
Shell :: update grub archlinux 
Shell :: ubuntu 18 ffmpeg install 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =