asp-classic - 经典 ASP : How to list activated sessions?

标签 asp-classic

有没有办法在经典 ASP 中获取激活的 session 列表?

我想限制同时激活的 session 数。

最佳答案

这是一篇很好的文章,展示了一种方法:Active User Count Without Global.asa by Josh Painter

我想您必须更改一些细节,但这是您解决问题的方法。作者不使用 global.asa。

更简单的方法是 Hook Sesssion_OnStartSession_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/

相关文章:

php - 定期从服务器端调用函数?

sql-server - 对经典 ASP 的脚本攻击

c# - 如何在 vb.net/c# 或 vbscript 中创建 ISAPI 过滤器 DLL

sql-server - 无效的列名 'False'(经典asp,表编辑问题)

asp-classic - 从经典 Asp 返回对象

javascript - 将表列数据库结果文本复制到剪贴板

debugging - VBScript/ASP-Classic "Stop"语句未进入调试器

sql - 在不同的数据库服务器上选择 2 个表上的查询

web-services - 从经典的 asp 页面调用 REST web 服务

html - 按钮在 Chrome 中不起作用