What is the default Django session lifetime and how to change it?

Question:

I can’t find a setting for the default session lifetime in https://docs.djangoproject.com/en/1.10/ref/settings/.

I know this can be changed manually (How to expire Django session in 5minutes?).

Asked By: Siegmeyer

||

Answers:

The setting you are looking for is SESSION_COOKIE_AGE, the default value is 1209600 which is two weeks, in seconds.

Answered By: aumo

You can change the default Django session lifetime by setting SESSION_COOKIE_AGE to "settings.py" as shown below. By default, SESSION_COOKIE_AGE is 1209600 seconds(2 weeks):

# "settings.py"

SESSION_COOKIE_AGE = 180 # 3 minutes

SESSION_COOKIE_AGE

Default: 1209600 (2 weeks, in seconds)

The age of session cookies, in seconds.

Answered By: Kai – Kazuya Ito