473,796 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count visitors on my website

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?

Jul 13 '07 #1
32 4285
..oO(Ciaran)
>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?
You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

Micha
Jul 13 '07 #2
In article <6u************ *************** *****@4ax.com>,
Michael Fesser <ne*****@gmx.de wrote:
>.oO(Ciaran)
>>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?

You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.
The VBulletin software not only says how many users are logged in and
using the forum, but also lists their names.

It is reasonable to assume that for a site like a forum, if a user
logs in, that user will probably still be looking at the forum a
minute after the user's most recent activity. It should be easy to
keep a running database of users whose recent activity is less than,
say, 5 minutes ago. The list could be displayed alphabetically or
sorted by timestamp.

-A
Jul 14 '07 #3
axlq wrote:
In article <6u************ *************** *****@4ax.com>,
Michael Fesser <ne*****@gmx.de wrote:
>.oO(Ciaran)
>>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?
You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

The VBulletin software not only says how many users are logged in and
using the forum, but also lists their names.

It is reasonable to assume that for a site like a forum, if a user
logs in, that user will probably still be looking at the forum a
minute after the user's most recent activity. It should be easy to
keep a running database of users whose recent activity is less than,
say, 5 minutes ago. The list could be displayed alphabetically or
sorted by timestamp.

-A
No, that is not a reasonable assumption. Some people may stay 10
second, others 10 hours.

As Micha said - HTTP is a stateless protocol. All you really know is
that the user is *probably* still there when a response is being sent.
But even that is not for sure.

Any other figure is a pure crap shoot.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 14 '07 #4
Michael Fesser <ne*****@gmx.de writes:
.oO(Ciaran)
>>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?

You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

Micha
So you clearly have no clue.

PHP maintains sessions and the user can be logged for that duration and
therefore only counted once.
Jul 15 '07 #5
rf

"Hadron" <ha*********@gm ail.comwrote in message
news:87******** ****@gmail.com. ..
Michael Fesser <ne*****@gmx.de writes:
>.oO(Ciaran)
>>>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?

You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

Micha

So you clearly have no clue.
Ha!
PHP maintains sessions and the user can be logged for that duration and
therefore only counted once.
And it clearly says right up there in the Original Post: "not logged in".

That means no session.

And even if there *is* a session how do you know the user hasn't opened a
new tab and is busily looking at somebody elses site, or turned their
computer off, or simply wandered off down to the pub for lunch?

With sessions you can tell how many people have used your login form and
have yet to use your logout form, or yet to be timed out. You can not tell
how many people are "browsing the site".

I administer several sites that use logins. Sometimes I visit one only to
find that I had last "logged in" several days ago and my browser is still
hanging on to the session cookie.

--
Richard.
Jul 15 '07 #6
..oO(Hadron)
>Michael Fesser <ne*****@gmx.de writes:
>Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

So you clearly have no clue.
Sure?
>PHP maintains sessions and the user can be logged for that duration and
therefore only counted once.
You are the second one in this thread who obviously didn't read the "not
logged in" in the original post.

And what does session counting tell you? Sessions can be open for hours
without any user interaction. The user could have died already in front
of his monitor and his session would still be open.

Whatever way you go - it's always just guessing. So why bother at all?
Why show a questionable "informatio n" that is of absolutely no use for
the visitor? Just to show how cool and active the "community" is? If you
want that you can use rand() - it's much easier than all others methods.

Micha
Jul 15 '07 #7
>>>>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?

You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

Micha

So you clearly have no clue.

Ha!
>PHP maintains sessions and the user can be logged for that duration and
therefore only counted once.

And it clearly says right up there in the Original Post: "not logged in".

That means no session.
No, "not logged in" does *NOT* mean "no session". For some login
setups, "no session" (e.g. they've got cookies turned off, and
you're not passing the session identifier in the URL) means "no
ability to sustain a login", but that's a completely different
issue.
>And even if there *is* a session how do you know the user hasn't opened a
new tab and is busily looking at somebody elses site, or turned their
computer off, or simply wandered off down to the pub for lunch?
Or is talking on the phone, or is asleep, or ...
>With sessions you can tell how many people have used your login form and
have yet to use your logout form, or yet to be timed out. You can not tell
how many people are "browsing the site".
Sessions do not require a login form. But even if you have a "logout form",
users hardly ever use it unless there's some really sensitive information
or control with it (like online banking). About the only thing you can
do is assume a timeout: no hit in N minutes for that session, they've
probably left.
>I administer several sites that use logins. Sometimes I visit one only to
find that I had last "logged in" several days ago and my browser is still
hanging on to the session cookie.
If you're trying to count "unique visitors", you've got an even worse
problem. Spammers often sign up multiple accounts for the same user.
Jul 15 '07 #8
Michael Fesser <ne*****@gmx.de writes:
.oO(Hadron)
>>Michael Fesser <ne*****@gmx.de writes:
>>Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

So you clearly have no clue.

Sure?
>>PHP maintains sessions and the user can be logged for that duration and
therefore only counted once.

You are the second one in this thread who obviously didn't read the "not
logged in" in the original post
I am reading the "stateless protocol" stuff above and replying to that
in the context of PHP.
..
>
And what does session counting tell you? Sessions can be open for hours
without any user interaction. The user could have died already in front
of his monitor and his session would still be open.
That's not the issue. Clearly something on a server cant know IF he is
reading the page or not. You can only go on the connections.

"Currently online" has a meaning - and that is that HIS PC is
connected. The rest is guesswork.
>
Whatever way you go - it's always just guessing. So why bother at all?
Absolute tosh.
Why show a questionable "informatio n" that is of absolutely no use for
the visitor? Just to show how cool and active the "community" is? If you
want that you can use rand() - it's much easier than all others
methods.
As I said - you are clueless.
>
Micha
--
Jul 15 '07 #9
"rf" <rf@invalid.com writes:
"Hadron" <ha*********@gm ail.comwrote in message
news:87******** ****@gmail.com. ..
>Michael Fesser <ne*****@gmx.de writes:
>>.oO(Ciaran)

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?

You can use rand().

Such "statistics " are never accurate. HTTP is a stateless protocol,
there's no such thing like a "currently online user". A user comes,
sends a request, gets a response and is gone. Next request, next user.

Micha

So you clearly have no clue.

Ha!
>PHP maintains sessions and the user can be logged for that duration and
therefore only counted once.

And it clearly says right up there in the Original Post: "not logged
in".
So? Who is talking about "logged in"? I am talking about PHP sessions.
>
That means no session.
Rubbish.
>
And even if there *is* a session how do you know the user hasn't opened a
new tab and is busily looking at somebody elses site, or turned their
computer off, or simply wandered off down to the pub for lunch?
So what if they are? They are still connected and have a session. Of
course we can not know if that user is actually LOOKING - but they *ARE*
connected.
>
With sessions you can tell how many people have used your login form and
have yet to use your logout form, or yet to be timed out. You can not tell
how many people are "browsing the site".
Yes you can. Because even if they are not physically looking, they ARE
still browsing. Sure, we dont know if the use is asleep or on the toilet
but he IS still maintaining a session.
>
I administer several sites that use logins. Sometimes I visit one only to
find that I had last "logged in" several days ago and my browser is still
hanging on to the session cookie.
If you administer sites then I am surprised you are so clueless in the
context of a PHP site.
Jul 15 '07 #10

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

Similar topics

14
2184
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
3628
by: cc | last post by:
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...
0
3230
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...
1
2340
by: drexcol | last post by:
I am a php newbie and am trying to write a script that will direct visitors to specific pages on my website based on which of several url’s they have entered (all are aliases of the main website). While all visitosr will be directed to the same website, I want them to start at specific pages based on their interests, rather than having to drill down from various menus. For example, let us call the main doman abc.com. I have the following...
0
1612
by: ashutoshkataruka | last post by:
Is your website getting very less no. of visitors .If so, then post your website to http://goodtolove.com to get unlimited visitors for lifetime...No need to pay a penny.
6
1442
by: tenxian | last post by:
It is said as for code, developing a website that can stand 10,000 concurrent visitors is much different from developing a website that can stand 1,000 concurrent visitors, is it true?
1
3069
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
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
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
9055
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
7552
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
6793
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();...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.