473,804 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count of current visitors

cc


From the popular website At this link:
http://www.w3schools.com/asp/asp_globalasa.asp

I got this code, but it does not work on my server... I can open three
IE browsers and watch the count go to three. Upon closing two, each
having separate sessions (and session ID's of course), the count
remains at three! I'm not looking for alternative ways of doing this:
I'm interested in knowing why the application variable does not get
reduced upon ending the session by closing the browser. Any ideas?

Thanks,
See below:

The Global.asa file:

<script language="vbscr ipt" runat="server">
Sub Application_OnS tart
Application("vi sitors")=0
End Sub

Sub Session_OnStart
Application.Loc k
Application("vi sitors")=Applic ation("visitors ")+1
Application.UnL ock
End Sub

Sub Session_OnEnd
Application.Loc k
Application("vi sitors")=Applic ation("visitors ")-1
Application.UnL ock
End Sub
</script>

To display the number of current visitors in an ASP file:

<html>
<head>
</head>
<body>
<p>
There are <%response.writ e(Application(" visitors"))%>
online now!
</p>
</body>
</html>

Jul 19 '05 #1
5 3628
Did you refresh your 1° page after closing 2 and 3 ?
Jul 19 '05 #2
cc@cc.com wrote:
From the popular website At this link:
http://www.w3schools.com/asp/asp_globalasa.asp

I got this code, but it does not work on my server... I can open three
IE browsers and watch the count go to three. Upon closing two, each
having separate sessions (and session ID's of course), the count
remains at three! I'm not looking for alternative ways of doing this:
I'm interested in knowing why the application variable does not get
reduced upon ending the session by closing the browser. Any ideas?

This seems to be a very prevalent misconception.

The session does not end when the user closes his browser. Think about it.
How can the server know when a user closes his browser? Answer: it can't.
HTTP is a stateless protocol. There is no "signal" sent to the server when a
user closes his browser, or navigates to another website. The only way a web
server has of knowing a session is still in use is if it receives requests
for pages with the session ID in the request headers.

There are only two ways a session will end:

1. A Session.Abandon statement is executed
2. The session's timeout period is exceeded, i.e., the server receives no
new requests for pages containing that session id for a longer period of
time than the session's timeout setting.

So, in the scenario you describe above: if your session timeout setting is
at the default value of 20 min., the user count will get adjusted 20 min.
after the user closes his browser.

Aaron describes a way to get a more accurate count of current users using a
database in this article:
http://www.aspfaq.com/show.asp?id=2491

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #3
Sessions timeout after n minutes (default is 20 I think) so you'll
have to be patient (or change the setting)

cc@cc.com wrote in message news:<41******* ********@news.d allas.sbcglobal .net>...
From the popular website At this link:
http://www.w3schools.com/asp/asp_globalasa.asp

I got this code, but it does not work on my server... I can open three
IE browsers and watch the count go to three. Upon closing two, each
having separate sessions (and session ID's of course), the count
remains at three! I'm not looking for alternative ways of doing this:
I'm interested in knowing why the application variable does not get
reduced upon ending the session by closing the browser. Any ideas?

Thanks,
See below:

The Global.asa file:

<script language="vbscr ipt" runat="server">
Sub Application_OnS tart
Application("vi sitors")=0
End Sub

Sub Session_OnStart
Application.Loc k
Application("vi sitors")=Applic ation("visitors ")+1
Application.UnL ock
End Sub

Sub Session_OnEnd
Application.Loc k
Application("vi sitors")=Applic ation("visitors ")-1
Application.UnL ock
End Sub
</script>

To display the number of current visitors in an ASP file:

<html>
<head>
</head>
<body>
<p>
There are <%response.writ e(Application(" visitors"))%>
online now!
</p>
</body>
</html>

Jul 19 '05 #4
> > I got this code, but it does not work on my server... I can open three
IE browsers and watch the count go to three. Upon closing two, each
having separate sessions (and session ID's of course), the count
remains at three! I'm not looking for alternative ways of doing this:
I'm interested in knowing why the application variable does not get
reduced upon ending the session by closing the browser. Any ideas?

This seems to be a very prevalent misconception.

The session does not end when the user closes his browser. Think about it.
How can the server know when a user closes his browser? Answer: it can't.

True, and I think people get confused because if they do close a
browser window, then open a new one, they get a new session.
Jul 19 '05 #5
cc
On Mon, 2 Aug 2004 06:29:21 -0400, "Bob Barrows [MVP]"
<re******@NOyah oo.SPAMcom> wrote:

I've been developing on the IIS platform since '98, and I've never
needed this counter functionality before. And this caught me off
guard. OF COURSE! The browser isn't going to send a last http call
before the .exe ends, so the server won't know when it closes.

I could SWEAR I read in one of those WROX books that session ended on
closing the browser, and that kinda' stuck with me.

Anyway... what's a 20 minute delay in the scope of all the other stuff
we have to deal with.
cc@cc.com wrote:
From the popular website At this link:
http://www.w3schools.com/asp/asp_globalasa.asp

I got this code, but it does not work on my server... I can open three
IE browsers and watch the count go to three. Upon closing two, each
having separate sessions (and session ID's of course), the count
remains at three! I'm not looking for alternative ways of doing this:
I'm interested in knowing why the application variable does not get
reduced upon ending the session by closing the browser. Any ideas?

This seems to be a very prevalent misconception.

The session does not end when the user closes his browser. Think about it.
How can the server know when a user closes his browser? Answer: it can't.
HTTP is a stateless protocol. There is no "signal" sent to the server when a
user closes his browser, or navigates to another website. The only way a web
server has of knowing a session is still in use is if it receives requests
for pages with the session ID in the request headers.

There are only two ways a session will end:

1. A Session.Abandon statement is executed
2. The session's timeout period is exceeded, i.e., the server receives no
new requests for pages containing that session id for a longer period of
time than the session's timeout setting.

So, in the scenario you describe above: if your session timeout setting is
at the default value of 20 min., the user count will get adjusted 20 min.
after the user closes his browser.

Aaron describes a way to get a more accurate count of current users using a
database in this article:
http://www.aspfaq.com/show.asp?id=2491

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2185
by: deko | last post by:
Below are the contents file that has the IP address and time of visit of visitors to a website. 68.122.69.241|1089822686 68.122.69.241|1089823630 68.122.69.241|1089823638
5
7104
by: toedipper | last post by:
Hello, I am developing a site using php and mysql and I would like to be able to let visitors know how many other visitors are currently browsing the site i.e. 'There are currently x amount of visitors browsing this site' You can see this in action in the following sites but I am not sure what technology they use www.recruitni.com (about 1/3 down the page) and also www.scancom.co.uk on the left hand side.
1
1449
by: Greg Collins [InfoPath MVP] | last post by:
Is it possible to get a count of active visitors currently on your site?
0
3231
by: lkrubner | last post by:
The idea I'm trying to get at is that I want the tag info for the tag "photography", and I want the date, and I want a count of any comments a tag may have. This following query gets back all the info I want, provided the tag has at least one comment. If It doesn't have any comments, it doesn't show up in the return. But if it has a count of zero, I just want it to come back with a count of zero, I don't want it to disappear from the...
6
2817
by: Sjaakie | last post by:
Hi, Is HttpContext.Current.User unique for each visitor or is it shared across an application? Have some problems that might have to do with this and found contradictory answers on this question. Thanks!
4
2251
by: Jofio | last post by:
I am developing a picture gallery - pictures of landscapes and various other subjects. My site has a left panel consisting of thumbnails of pictures which when clicked displays the corresponding bigger picture of it. Problem is I am trying to keep count of each and every picture downloaded (saved to load computers by visitors). Is it within javaScript realm o do that? I thought of using onLoad event handler ... but not sure. thanks
18
2474
by: damezumari | last post by:
I would like to know how many of the visitors to my site has js enabled and how many has it turned off. I haven't found a simple solution searching Google groups so I suggest the following using php and mysql: Create a table mc_jscount table in mysql with two fields nonjs (int) and js (int). Create one record with nonjs and js set to zero. Put this code at the top of your page:
32
4286
by: Ciaran | last post by:
Hi I've seen this a few places - The site lists off the number of people (not logged in) currently browsing the site. How can I do this with php / mySQL please?
1
3070
by: dez5000 | last post by:
I'm trying to get a report by location that would list the number of visits to the location for the month but also count the number of unique visitors to that location. I have a table of data with Location, VisitorId, and DateOfVisit. I then have a query to filter by a single month and then base my report on that query. In my report I have a group header for the location and I can do a count of the VistorId or DateOfVisit fields to get a...
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.