News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Global.asa Example

Started by VelMurugan, Dec 16, 2008, 06:23 AM

Previous topic - Next topic

VelMurugan

Global.asa Example

In this example we will create a Global.asa file that counts the number of current visitors.

The Application_OnStart sets the Application variable "visitors" to 0 when the server starts.
The Session_OnStart subroutine adds one to the variable "visitors" every time a new visitor arrives.
The Session_OnEnd subroutine subtracts one from "visitors" each time this subroutine is triggered

The Global.asa file:


<script language="vbscript" runat="server">
Sub Application_OnStart
Application("visitors")=0
End Sub

Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub

Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>



To display the number of current visitors in an ASP file:

<html>
<head>
</head>
<body>
<p>
There are <%response.write(Application("visitors"))%>
online now!
</p>
</body>
</html>


Source : ExpertsForge