[Django]-Increase time of Django Sessions

5👍

It is driven by a setting called SESSION_COOKIE_AGE

Documentation here

If you want to set it to 18 days , in your settings file,

SESSION_COOKIE_AGE = 18 * 24 * 60 * 60

1👍

Default SESSION_COOKIE_AGE is 1209600 that is 2 week in seconds.

Take a look at the session middleware and its settings here is the link:
https://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions

and also visit https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-cookie-age
link and it will provide all the session information that you required.

As said my @karthikr you can set SESSION_COOKIE_AGE = 18 * 24 * 60 * 60

And if there is any case like a website that requires us to log a user out after N minutes of inactivity. At this time you can use the same settings

SESSION_COOKIE_AGE
Default: 1209600 (2 weeks, in seconds)
The age of session cookies, in seconds.

SESSION_SAVE_EVERY_REQUEST
Default: False

Whether to save the session data on every request. If this setting is False (default), then the session data will only be saved if it has been modified. In short, if any of its dictionary values have been assigned or deleted.

Leave a comment