In-depth study of Application and Session objects (including global. asa) 3
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
III. Global. asa
The Application and Session objects of ASP reflect the features that other ASP built-in objects do not have-events. Each visitor accesses the server and triggers an OnStart event (the first visitor simultaneously triggers the OnStart event of the Application and Session, but the Application is prior to the Session ), an OnEnd event is triggered at the end of each guest Session (the OnEnd event of the Application and Session is triggered at the end of the last guest Session, but the Session is prior to the Application ).
OnStart and OnEnd events are generally used to count the number of online users in the virtual community, and modify the online offline status of users. To define these two events, you need to write the code in the Global. asa file and put the file in the root directory of the site (Inetpubwwwroot by default ). In addition, the Application and Session objects stipulate that all ASP built-in objects (Response, Request, Server, Session...) except Application objects cannot be used in OnEnd events. The following is an example of how to count the number of online users in a virtual community to show how to use these two events.
Global. asa is located in the d: Inetpubwwwroot directory.
Default. asp is located in the d: Inetpubwwwroot Directory. The logon page of the virtual community is displayed.
Login. asp is located in the d: Inetpubwwwroot Directory. It is used to detect the user name and password entered by the user.
Index. asp is located in the d: Inetpubwwwroot directory, the home page of the virtual community
Bbs. mdb is located in the d: Inetpubwwwroot directory, the database that stores user information
Database (ACCESS) structure:
=== Bbs table ===
Id User id, long integer
Name username, text type
Code password, text type
Online Status, yes/no
=== Global. asa ===
<Script LANGUAGE = "VBScript" RUNAT = "Server">
Application ("online") = 0
If session. contents ("pass") then', determine whether it is the user's Session_OnEnd
Application ("online") = application ("online")-1
=== Login. asp ===
... 'Password verification, connect to the database, and check whether the user name and password entered by the user are correct
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.