Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application-variable problem

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
I have a problem using an application variable in my global.asa. All other variables seem to work just fine. I don't think that the problem is in my code, so I wonder what can be the problem. ActiveUsers is the variable that causes problems ; In the beginning it works very well, but when a user visits my site, it (sometimes) jumps more than one number (even 17!). Working offline, the ActiveUsers-var doesn't immediately decrement when a users ends the session. This is my code:

Code:
<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
SUB Application_OnStart 
	 Application.Lock 
	' number of users currently on the site  
	 Application ( &quot;ActiveUsers&quot; ) = 0 
	' number of users on the site today 
	 Application ( &quot;UsersToday&quot; ) = 0 
	' total number of users on the site 
	 Application ( &quot;TotalUsers&quot; ) = 0 
	' number of pages viewed today  
	 Application ( &quot;PagesToday&quot; ) = 0 
	' total number of pages viewed  
	 Application ( &quot;TotalPages&quot; ) = 0 
	' remember todays date  
	 Application ( &quot;Today&quot; ) = date() 
	' date since startup 
	 Application ( &quot;DateSince&quot; ) = date() 
	 Application.Unlock 
END SUB 

SUB Application_OnEnd 
END SUB 

SUB Session_OnStart 
	' Session.timeout = 15 
	 Application.Lock 
	' one more active user 
	 Application ( &quot;ActiveUsers&quot; ) = Application ( &quot;ActiveUsers&quot; ) + 1 
	' total users and total pages + 1 
	 Application ( &quot;TotalUsers&quot; ) = Application ( &quot;TotalUsers&quot; ) + 1 
	' is it a new day? 
	 nDate = Date() 
	 if Application ( &quot;Today&quot; ) = nDate then  
		' same day, so increment users today  
		 Application ( &quot;UsersToday&quot; ) = Application ( &quot;UsersToday&quot; ) + 1  
	 else 
		' new day, so restart count  
		 Application ( &quot;Today&quot; ) = nDate  
		 Application ( &quot;UsersToday&quot; ) = 1  
		 Application ( &quot;PagesToday&quot; ) = 1  
	 end if 
	 Application.Unlock 
END SUB 

SUB Session_OnEnd 
	 Application.Lock 
	' one less active user 
	 Application ( &quot;ActiveUsers&quot; ) = Application ( &quot;ActiveUsers&quot; ) - 1 
	 Application.Unlock 
END SUB 
</script>

On another page I increment the page hits (but this doesn't involve the ActiveUsers variable):
Code:
<% response.buffer = true %>
<% Application.Lock %>
<% Application(&quot;PagesToday&quot;)=Application(&quot;PagesToday&quot;)+1 %>
<% Application(&quot;TotalPages&quot;)=Application(&quot;TotalPages&quot;)+1 %>
<% Application.Unlock %>
For a look at the numbers goto -> SITE-INFO (site for the moment just in Dutch, sorry ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top