BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
Microsoft ASP
The Session Object
The Server.ScriptTimeOut Property
The Server.URLEncode Method
The Server.Transfer Method
The Server.MapPath Method
The Server.HTMLEncode Method
The Server.GetLastError Method
The Server.Execute Method
The Server.CreateObject Method
The Server Object
The Response.Status Property
The Response.PICS Property
The Response.LCID Property
The Response.IsClientConnected Property
The Response.ExpiresAbsolute Property
The Response.Expires Property
The Response.Cookies Property
The Response.ContentType Property
The Response.CodePage Property
The Response.Charset Property
<< LAMP
 

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :03/24/2008
Times viewed :288

 

The Session.OnEnd() Event

Introduction

The Session.OnEnd event applies to the Session object. In ASP there is a session for visitors who has their cookies turned on. If they do not have cookies turned on, these events won't run. The OnEnd event is called whenever a session ends or times out. See the timeout property of the session object to find out more about timeouts. Usually you load something in the OnStart event and you unload it on the OnEnd event.  The OnEnd event is useful for clearing up any resources when the user leaves. In the following OnStart event we have an application variable called "CurrentUserCounts" and we add 1 to it, every time another user visits the site. In this OnEnd event we minus 1 from an application variable called "CurrentUserCounts", because the user has left the website.

Example (global.asa)

<script language="vbscript" runat="server">

Sub Session_OnStart

       Application("CurrentUserCounts") = Application("CurrentUserCounts") + 1

       session("memberId") = trim(request.cookies("member")("memberId"))

End Sub

Sub Session_OnEnd

       Application("CurrentUserCounts") = Application("CurrentUserCounts") - 1

End Sub

</script>

In this example, we use the application variable called "CurrentUserCounts" in our front page of the website to display how many users are online at the moment. The variable "CurrentUserCounts" is written out using the write method of the ASP response object.

Example (session_object_event_onend_example.asp)

<%

       response.write Application ("CurrentUserCounts")

%>

Output

 The above screenshot shows two open browsers. The first one shows only one user online. This browser was opened first. After that another browser has been opened and the number of users has increased by one, therefore the second browser shows now two users.


Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C
Immediate ASP.NET/C# Openings for C

View all Jobs (Add yours)
View all CV (Add yours)



spoc
swimming pool contractor
teleconferencing service
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP