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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application/global.asa problem

Status
Not open for further replies.

motte

Programmer
May 31, 2001
155
0
0
US
Hi all,

I've been experimenting with the global.asa file lately and have a problem dealing with arrays. I want to see how many sessions are currently open, and at the same time, find there remote ip address. I can get the number of sessions at any one time, but when I loop thru my array (which is actually an application variable), I can only see the latest ip address but the correct num of sessions. The other ip addresses are blank. Can you please take a look at my code? Any suggestions would be helpful.
***********************************************************
global.asa below
************************************************************
<script language=&quot;vbscript&quot; runat=&quot;server&quot;>
sub Application_OnStart
application(&quot;USERS&quot;)=0
dim urls(0)

application(&quot;URLS&quot;)=urls
end sub

sub session_onstart
session.timeout=1
session(&quot;Start&quot;)=now

application.lock
application(&quot;USERS&quot;) = application(&quot;USERS&quot;) + 1
size=application(&quot;USERS&quot;)
redim preserve urls(size-1)

application.unlock

application.lock
urls(size-1)=request.servervariables(&quot;REMOTE_ADDR&quot;)
application(&quot;URLS&quot;)=urls
application.unlock
end sub

sub session_onend
application.lock
application(&quot;USERS&quot;)=application(&quot;USERS&quot;) - 1
application.unlock

redim urls(size-1)
session(&quot;URL&quot;)=request.servervariables(&quot;REMOTE_ADDR&quot;)
urls(size-1)=session(&quot;URL&quot;)
application(&quot;URLS&quot;)=urls
end sub
</script>
************************************************************
page displaying sessions/ip addresses below
************************************************************
<!-- #include virtual=&quot;/global.asa&quot; -->
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<%
response.write (&quot;This many sessions are open: &quot; & application(&quot;USERS&quot;) & &quot;<br>&quot;)

dim counter
for counter=0 to ubound(application(&quot;URLS&quot;))
response.write counter & &quot;: &quot; & application(&quot;URLS&quot;)(counter) & &quot;<br>&quot;
next
%>

</BODY>
</HTML>
************************************************************

Hopefully you can figure out my mess.

Mike
 
Hi Mike

Have you checked out the below site:


The author gives you all the code you need, as he does the exact samething on his site. I haven't actually looked at it, but give it a go.

HTH

Tim
 
Tim,

Thanks for your post. Though it doesn't handle what I am looking for, it has some good tips on things I can use for future use. My problem concerns the array and why old ip addresses are getting misplaced but the array can continue to grow or shrink...

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top