CoFa
CoFa

Reputation: 23

Set different logout time for different users in django?

Can anyone know how to set session timeout per user in Django? I'm building a system where I need to set a user timeout session, if a user is failed to perform any action till a timeout setting then he will be logout of the system. Is this possible in Django?

Upvotes: 2

Views: 406

Answers (1)

Fahad Shahid
Fahad Shahid

Reputation: 146

Yes, there is a way. You can use request.session.set_expiry(<VALUE>) in your login view to dynamically set session expiry based on some rule

https://docs.djangoproject.com/en/3.2/topics/http/sessions/#django.contrib.sessions.backends.base.SessionBase.set_expiry

Upvotes: 2

Related Questions