Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想通知用户她也从其他计算机登录,并可以选择关闭这些其他会话。不幸的是,在不直接破解数据库的情况下,如何在 Django 中做到这一点并不是很明显。
您可以在访问者 cookie 中存储多个令牌,并根据数据库中的令牌列表验证它们。如果它们是 db 用户配置文件中的多个令牌,您将确保用户从不同的浏览器登录。刷新每个令牌将断开用户与其他计算机的连接。
您可以通过检查会话是否过期来找到登录的用户会话。您可以通过以下方式捕获登录的用户会话
Session.objects.filter(expire_date__gte=timezone.now())