Global.asa file,
What is a Global.asa file? It is actually an optional file where program writers can specify event scripts and declare objects with session and application scopes. The contents of this file are not intended to be displayed to the user, but are used to store event information and objects that are used globally by the application. The name of the file must be global.asa and must reside in the application's root directory. There can be only one Global.asa file per application. The contents are as follows:
<script language="vbscript" runat="server">
sub Application_Onstart '对当前在线人数及访问总量的初始化.
Application("online")=0
Application("counter")=0
End Sub
Sub session_Onstart
session.timeout=5 '设置网页到期时间为5分钟
application.lock
application("online")=application("online")+1
application("counter")=application("counter")+1
application.unlock
End Sub
Sub session_OnEnd
Application.lock
Application("online")=Application("online")-1
Application.unlock
End Sub
</script>
Call the page code. test.asp
<%
' Increase current number limit processing, prompt trainees, and send mail
' Parameter description
' Subject: Message headers
' MailAddress: Address of the outgoing server, such as smtp.163.com
' Email: Recipient email Address
' Sender: Name of sender
' Content: Message contents
' Fromer: Sender's email address
Sub sendaction (subject, email, sender, content)
Set JMail = Server.CreateObject ("Jmail.message")
Jmail.charset = "gb2312" message character set, default to "Us-ascii"
Jmail.from = Strmailuser ' Sender address
jmail.fromname = Sender ' sender name
Jmail.subject =subject
Jmail.mailserverusername = Strmailuser ' Authenticated user name
Jmail.mailserverpassword = Strmailpass ' authenticated password
jmail.priority = 3 ' Send message type 1 to Super 3 for normal
Jmail.addrecipient (email)
Jmail.body = Content
Jmail.send (strmailaddress)
End Sub
Dim title,stremail,strmailadress,strsender,strcontent
Dim Strmailaddress,strmailpass,strmailuser,jmail
If Application ("online") >=1 Then
' The example of calling this sub
title = Request ("title")
strcontent = "Hello, current online number is" &application ("on-line")
Strsender = Request ("name") ' Sender name
Stremail = "a375267603@163.com" ' recipient's mailbox, can be changed to another mailbox
strmailaddress = "mail.cdce.cn" ' Outgoing server address example: smtp.163.com (for 163 server address)
Strmailuser = "zenghai@cdce.cn" ' Sender username
Strmailpass = "8888" ' Sender account password
Call SendAction (title,stremail,strsender,strcontent)
strshowmessage = "Module name: verifystudent[exceeds the number limit]| details: The number of currently logged on examination systems has exceeded the server limit" "& Application (" Online ") &" ", Please login again later! "
End If
%>