• Welcome to Valhalla Legends Archive.
 

Active Users [ASP.NET]

Started by quasi-modo, December 09, 2003, 10:28 PM

Previous topic - Next topic

quasi-modo

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.

<%@ 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>

and the global.asax to control the application on end/begin events

<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>
WAR EAGLE!
Quote(00:04:08) zdv17: yeah i quit doing that stuff cause it jacked up the power bill too much
(00:04:19) nick is a turtle: Right now im not paying the power bill though
(00:04:33) nick is a turtle: if i had to pay the electric bill
(00:04:47) nick is a turtle: id hibernate when i go to class
(00:04:57) nick is a turtle: or at least when i go to sleep
(00:08:50) zdv17: hibernating in class is cool.. esp. when you leave a drool puddle