我希望在用户处于非活动状态一段时间后删除会话。
我尝试了set_expiry(300)
和SESSION_COOKIE_AGE = 5 * 60
,但即使用户活跃,会话也没有延长。
您具有用于注销部分的正确设置,但您的系统未通知会话表的活动请求,因此系统明确需要将新请求保存到会话表,这将更新超时到期。
在你的Settings.py
SESSION_EXPIRE_AT_BROWSER_CLOSE = True # opional, as this will log you out when browser is closed
SESSION_COOKIE_AGE = 300 # 0r 5 * 60, same thing
SESSION_SAVE_EVERY_REQUEST = True # Will prrevent from logging you out after 300 seconds