Valhalla Legends Forums Archive | Web Development | Active Users [ASP.NET]

AuthorMessageTime
peofeoknight
My friend wanted a copy of my active users script seen on my site, www.clanknights.vze.com , so I isolated it and saved it, I uploaded it to my personal server for others to download, but I thought I would post it here if anyone wants it.
[code]
<%@ 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:&nbsp;" & (Application("user_sessions").ToString()) & "&nbsp;users browsing this site"
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>
[/code]
and the global.asax to control the application on end/begin events
[code]
<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>
[/code]
December 10, 2003, 4:28 AM

Search