Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2005, 02:58 PM
Authorized User
 
Join Date: Mar 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to arimakidd
Default Debugging Global.asa file

I am using a global.asa file to keep track of the time users spend on the main page. The code in the file is as follows:
Code:
<script language="vbscript" runat="server">

sub Application_OnStart
Session("start_time") = time()
end sub

sub Application_OnEnd

end sub

sub Session_OnStart
Session("end_time") = time()
Session("total_time") = Session("end_time") - Session("start_time")
end sub

sub Session_OnEnd

end sub

</script>
The problem is that my start time and end time is always exactly the same and I always get zero for my "total_time". What's wrong with it.

 
Old August 23rd, 2005, 03:15 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi arimakidd,

You seem to be mixing up events.

Application_OnStart fires when the entire application starts (e.g. on the first hit after IIS has started) and is *not* user related.

The "main page" is hard to track; Session_OnStart fires when the user hits *any* page in your site, beit the main page or a page 7 levels deep in your site. Session_OnEnd fires when you either explicitly end the Session (using Session.Abandon), the session times out (by default, this is 20 minutes after the last request has been made) or when the entire application is shut down (because you stop IIS for example).

If you want to track a single page, your best bet is to store an individual variable in session state. Not in the global.asa, but in the main page. Then other pages can assign another variable to the session and later you can compare the two values.
Another alternative is to use cookies or page level variables, like hidden fields.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Are functions allowed in global.asa file mat41 Classic ASP Basics 1 January 10th, 2008 01:58 AM
how to include file in global.asa beetle_jaipur Classic ASP Basics 1 April 18th, 2006 03:46 AM
Global.asa File Help gmoney060 Classic ASP Basics 19 September 27th, 2004 10:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.