PeOfEo
12-12-2003, 07:20 PM
I wrote this real quickly at the request of someone else and thought I would post it here
put this in a .aspx
<%@ Page Language="VB" Debug="true"%>
<script runat="server">
'========================
' Be sure to include the global.asax
' that comes w/ this file
'========================
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
lblusers.Text = "There are currently: " & (Application("user_sessions").ToString()) & " users browsing this page"
end Sub
</SCRIPT>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<Title>Active users</Title>
</HEAD>
<BODY>
<form runat="server">
<asp:Label
id="lblusers"
Text=""
style="font:11px ms sans serif, arial, helvetica"
runat="server"
/>
</form>
</BODY>
</HTML>
make this a global.asax
<script language="VBScript" runat="Server">
Sub Application_OnStart(Sender as Object, E AS EventArgs)
application("user_sessions") = 0
End Sub
Sub Application_OnEnd(Sender as Object, E AS EventArgs)
End Sub
Sub Session_OnStart(Sender as Object, E AS EventArgs)
application.lock()
application("user_sessions") = application("user_sessions") + 1
application.unlock()
End Sub
Sub Session_OnEnd(Sender as Object, E AS EventArgs)
application.lock()
application("user_sessions") = application("user_sessions") - 1
application.unlock()
End Sub
</script>
hope this helps someone ;)
you can see it in action at
http://quasi-ke.servebeer.com/files/ASP.NET_scripts/activeusers.aspx
put this in a .aspx
<%@ Page Language="VB" Debug="true"%>
<script runat="server">
'========================
' Be sure to include the global.asax
' that comes w/ this file
'========================
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
lblusers.Text = "There are currently: " & (Application("user_sessions").ToString()) & " users browsing this page"
end Sub
</SCRIPT>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<Title>Active users</Title>
</HEAD>
<BODY>
<form runat="server">
<asp:Label
id="lblusers"
Text=""
style="font:11px ms sans serif, arial, helvetica"
runat="server"
/>
</form>
</BODY>
</HTML>
make this a global.asax
<script language="VBScript" runat="Server">
Sub Application_OnStart(Sender as Object, E AS EventArgs)
application("user_sessions") = 0
End Sub
Sub Application_OnEnd(Sender as Object, E AS EventArgs)
End Sub
Sub Session_OnStart(Sender as Object, E AS EventArgs)
application.lock()
application("user_sessions") = application("user_sessions") + 1
application.unlock()
End Sub
Sub Session_OnEnd(Sender as Object, E AS EventArgs)
application.lock()
application("user_sessions") = application("user_sessions") - 1
application.unlock()
End Sub
</script>
hope this helps someone ;)
you can see it in action at
http://quasi-ke.servebeer.com/files/ASP.NET_scripts/activeusers.aspx