如何注销Django中的非活动用户?

时间:2019-02-15 06:37:26

标签: django

我希望当用户在一段时间内处于非活动状态时删除会话。

我尝试了 <asp:GridView ID="griditemdetails" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="No."> <ItemTemplate> <%#Container.DataItemIndex+1 %> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="Item Code" DataField="ProductCode"/> <asp:BoundField HeaderText="Name" DataField="ProductDesc"/> <asp:BoundField HeaderText="UPC" DataField="UBSCode"/> <asp:BoundField HeaderText="Quantity" DataField="qty"/> <asp:BoundField HeaderText="Scanned Quantity" /> <asp:BoundField HeaderText="Balanced Quantity" /> <asp:CommandField SelectText="View" ShowSelectButton="True" /> </Columns> </asp:GridView> set_expiry(300),但是即使用户处于活动状态,会话也没有扩展。

1 个答案:

答案 0 :(得分:0)

您有正确的退出部分设置,但系统未将活动请求通知会话表,因此系统明确需要将新请求保存到会话表,这将使超时更新过期。

在您的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
相关问题