且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎么知道哪些用户的会话ID已经过期(以及用户是否在线?)

更新时间:2023-12-02 16:01:16

会话数据意味着是私人用户,并不意味着要你的应用程序的其他部分访问(即,用户的上下文之外)。这意味着,做你想要使用会话什么将是艰苦和尴尬。

Session data is meant to be private to the user and is not meant to be accessible to the rest of your application (that is, outside the user's context). That means that doing what you want using the session is going to be hard and awkward.

有一个更好的替代方法是跟踪用户活动在一个单独的数据结构,并保持在Web服务器的内存(使用静态变量或System.Web.Caching命名空间),或在数据库中。

A better alternative would be to track user activity in a separate datastructure and keep that in the web server's memory (using a static variable or the System.Web.Caching namespace) or in the database.