有没有办法在经典 ASP 中获取激活的 session 列表?
我想限制同时激活的 session 数。
最佳答案
这是一篇很好的文章,展示了一种方法:Active User Count Without Global.asa by Josh Painter
我想您必须更改一些细节,但这是您解决问题的方法。作者不使用 global.asa。
更简单的方法是 Hook Sesssion_OnStart
和 Session_OnEnd
global.asa 中的事件以及从作为应用程序变量实现的 session 列表中添加/删除项目。
如果您只想要 计数 的 session ,你可以简单地这样做:
Sub Session_OnStart
Application.Lock
Application("count") = Application("count") + 1
Application.Unlock
End Sub
Sub Session_OnEnd
Application.Lock
Application("count") = Application("count") - 1
If Application("count") < 0 then ' Could only happen if some other function interfers
Application("count")=0
End If
Application.Unlock
End Sub
在你的 ASP 文件中
<%
Response.Write "There are currently " & Application("count") & "active sessions>"
%>
关于asp-classic - 经典 ASP : How to list activated sessions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/511180/