使其他用户的会话无效

发布于 2024-12-21 16:58:13 字数 431 浏览 1 评论 0原文

我创建了一个 asp.net 站点,它使用 Session 对象来存储每个登录用户的信息。为了检查用户是否仍然登录,我检查会话中是否存在某个对象。

系统使用Jasig CAS认证,单点登录部分工作正常(如:登录后,用户的Session对象被正确设置)。

CAS 还支持单点登录。发生这种情况的方式是 CAS 调用我网站上的 url,并带有一些有关 CAS 会话的参数。

我现在需要做的是使指定用户的所有 Session 对象无效。

如何从我网站上的页面使随机其他用户的 Session 对象无效?是否有一个我可以清除的数据库,是否全部都在内存中(如果我知道要查找什么,我可以查看 web.config)?

我以前见过这个问题,大多数答案是“在会话全局变量旁边保留一个全局变量,并检查该变量以查看用户是否应该注销”,但我不喜欢这样解决方案...

干杯!

I've made an asp.net site, which uses Session objects to store information for each logged in user. To check if a user is still logged in, I check if a certain object exists in the Session.

The system used Jasig CAS authentication, and the single sign on part works (as in: after the log in, the Session object of the user is set up correctly).

CAS also supports single sign out. The way this happens is that CAS calls a url on my site, with some parameters about the CAS session.

What I need to do now, is invalidate all Session objects for the specified user.

How can I, from a page on my site, invalid the Session object of a random other user? Is there a db I can clear, is it all in memory (I can look at web.config if I know what to look for)?

I've seen this question asked before, and most answers are "keep a global variable next to the Session global variable, and check that one too to see if the user should be logged out or not", but I don't like that solution...

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囚我心虐我身 2024-12-28 16:58:13

该会话在设计上是对个人用户私有的。因此,要放弃它,必须由用户来完成。

所以你可能不得不使用另一个列表 &检查一下。

但理想情况下,您不应将身份验证状态与会话联系起来。用户是否经过身份验证应该是独立的。然后,您可以通过查询身份验证状态来选择放弃会话。它还可以更轻松地实现诸如对登录用户进行计数等机制。确保仅从 1 个位置登录 - 如果您需要这些。

The session is by design private to individual users. Therefore to abandon it, it has to be done by the user.

So you might have to use another a list & check that.

Ideally though, you shouldn't tie your authentication state to the session. Whether the user is authenticated or not should be independent. You can then choose to abandon the session by querying the authentication state. It also makes it easier to implement mechanisms like counting logged in users & ensuring login from only 1 location - should you require these.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文