Configure Session Expiry
A snippet showing how to configure session expiry in Django.
# settings.py
SESSION_COOKIE_AGE = 1800 # 30 minutes
# views.py
def set_expiry(request):
request.session.set_expiry(300) # expire in 5 minutes
return HttpResponse("Session expiry set")
Explanation:
- Session will automatically expire after defined time.
- Category Sessions & Cookies
- Total Views 819
- Last Modified 24 June, 2026
- Tags #sessions #expiry #timeout #django
Previous snippet
Get Cookie from Request
Next snippet