473,804 Members | 2,116 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
32 4286
Hadron wrote:
>
>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.
No, you can't. All you know is at some time he started a session. You
don't know if they are still browsing your site (or some other site),
have closed their browser or even turned off their computer. You get NO
notification when someone closes their browser or moves on to another 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.

If you administer sites then I am surprised you are so clueless in the
context of a PHP site.
And I'm surprised you're so clueless as to how sessions and HTTP
protocol in general work.

He's right - browsers will hang onto session cookies forever, if you
tell them to. And sites will keep sessions open until your PHP code
destroys the session or it times out - which depends on the php.ini
settings.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 15 '07 #11
Hadron wrote:
Michael Fesser <ne*****@gmx.de writes:
>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.
Then you're not understanding what "stateless protocol" means.

Jul 15 '07 #12
rf
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:4L******** *************** *******@comcast .com...
Hadron wrote:
>>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.

Yep, you are totally clueless. You have absolutely no idea how this
works, and think you can pull the wool over experienced programmers' eyes.

You can do it to clueless clients. But you can't do it here.

And I pity those clients.
You will never convice these sort of people. They, without a clear
understanding of how the protocol actually works, will continually insist
that you can tally "current viewers". I've seen it time and time again. I've
even explained to some of them that they will completely miss the viewer
that has obtained a copy of their page from a corporate proxy (with of
course no access at all to their server), to no avail. They simply will not
understand. It's right up there with "N people have visited this site
since..." :-)

Just let them put their meaningless counters on their web sites. It does no
harm, providing, as you say, they are not telling their "clients" that it
has meaning.

--
Richard
Jul 15 '07 #13
Jerry Stuckle <js*******@attg lobal.netwrites :
Hadron wrote:
>Michael Fesser <ne*****@gmx.de writes:
>>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.

Then you're not understanding what "stateless protocol" means.

.
>>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.

This is correct.
Good. Because that is ALL this is about.
>
>"Currently online" has a meaning - and that is that HIS PC is
connected. The rest is guesswork.

There is no way to know if someone si "currently online". All you
know is he was online when he last requested a page. Anything else is
a guess.
Jesus H Christ.

Yes. But he IS connected. The session IS open. Whether he is physically
sat there is something we can NEVER know.
>
>>Whatever way you go - it's always just guessing. So why bother at all?

Absolute tosh.

Yep, your concept is absolute tosh.
Balderdash.
>
>>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.

Yep, you are totally clueless. You have absolutely no idea how this
works, and think you can pull the wool over experienced programmers'
eyes.
What ARE you talking about? I have implemented session based web sites.
>
You can do it to clueless clients. But you can't do it here.

And I pity those clients.
Ye gods. Go get a clue.
>
>>Micha
--
Jul 15 '07 #14
"rf" <rf@invalid.com writes:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:4L******** *************** *******@comcast .com...
>Hadron wrote:
>>>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.

Yep, you are totally clueless. You have absolutely no idea how this
works, and think you can pull the wool over experienced programmers' eyes.

You can do it to clueless clients. But you can't do it here.

And I pity those clients.

You will never convice these sort of people. They, without a clear
understanding of how the protocol actually works, will continually insist
that you can tally "current viewers". I've seen it time and time
again. I've
The viewer is the session for crying out loud.
even explained to some of them that they will completely miss the viewer
that has obtained a copy of their page from a corporate proxy (with of
course no access at all to their server), to no avail. They simply will not
understand. It's right up there with "N people have visited this site
since..." :-)

Just let them put their meaningless counters on their web sites. It does no
harm, providing, as you say, they are not telling their "clients" that it
has meaning.
I am frightened that you seem unable to understand such simple concepts.

You know, I think you should suggest to banks that they dont really know
if someone is there and should end all session based online banking.

Or they could do the SENSIBLE thing and ASSUME in many cases that the
fact that someone opened the session means that there is a HIGH
PROBABILITY that someone os THERE. Possibly implement a time out. Oh,
they do jus that.

Idiot.
Jul 15 '07 #15
Jerry Stuckle <js*******@attg lobal.netwrites :
Hadron wrote:
>>
>>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.

No, you can't. All you know is at some time he started a session.
You don't know if they are still browsing your site (or some other
site), have closed their browser or even turned off their computer.
You get NO notification when someone closes their browser or moves on
to another site.
You seem intent on complicating the issues beyond the obvious solutions
for the majority of cases.

Regardless of whether they "log out", time out or whatever, each new
session is a new visit. The counter can and does work "well enough".
Jul 15 '07 #16
On Jul 13, 10:45 pm, Ciaran <cronok...@hotm ail.comwrote:
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?
In case you'd like to know, at least of _some_ users, how long they
visited your
site, you may use AJAX.

Bind XHTMLRequest to a timer event, let this timer event fire e.g.
each minute
once and let the XHTMLRequest call a log script on your site.

Obviously, this technique on works, if clients enabled JavaScript.

Another option:

Embed an iFrame in each page of your site, set it the refresh e.g.
once each minute
in the iFrame's HTML HEAD section. Embed a <img in the iFrame's
source and
assign your logging script to the SRC-attribute of the IMG-element. To
not render
an error, you should return a transparent 1x1 image.

You need to be sensible regarding the initial client-request of this
iFrame, since
you need to assign somehow a unique ID for each new client.

___
Stefan

Jul 15 '07 #17
..oO(Hadron)
>Jerry Stuckle <js*******@attg lobal.netwrites :
>There is no way to know if someone si "currently online". All you
know is he was online when he last requested a page. Anything else is
a guess.

Jesus H Christ.
He's not connected at the moment. Didn't pay the bill I guess. SCNR
>Yes. But he IS connected.
Yes, for the blink of an eye. You know how HTTP usually works?

open connection -send request -get response -close connection
open connection -send request -get response -close connection
open connection -send request -get response -close connection
....

Even two subsequent page request from the _same_ user could come from
entirely different IP addresses (hint: proxys, load balancers)! There's
nothing like a connection in terms of "being connected to a website for
more than one request". Such thing simply not exists in HTTP.
>The session IS open.
Then you have to say that on the page. "10 users currently online" and
"10 sessions currently open" are two completely different things. While
the second information is accurate, it's absolutely meaningless for a
site visitor.
>Whether he is physically
sat there is something we can NEVER know.
Exactly. So you can't tell who's online ATM, because you can never know.

Micha
Jul 15 '07 #18
..oO(Hadron)
>Regardless of whether they "log out", time out or whatever, each new
session is a new visit. The counter can and does work "well enough".
So does rand(). Saves some CPU cycles as well.

Micha
Jul 15 '07 #19
>You will never convice these sort of people. They, without a clear
>understandin g of how the protocol actually works, will continually insist
that you can tally "current viewers". I've seen it time and time
again. I've

The viewer is the session for crying out loud.
Since for most practical purposes, sessions do not end EXCEPT by
the server applying an arbitrary timeout, this is a rather useless
definition of "viewer".

Oh, yes, if you are depending on cookies to do sessions (putting
it in the URL is often considered "too insecure"), someone with
cookies turned off will start a new session every page. If only
10% of the people have cookies turned off, that might not seem like
much, but if the average visitor generates 10 hits, your session
count is about double what it should be.

I suppose a bank can estimate how big to build its lobby by noting
how many "teller sessions" are still open. Obviously, if someone
makes a deposit in person, and the account is still open, they're
still in the bank lobby, right? (Accounts do have a timeout in
most states. It's called an escheat law. After so many years of
inactivity, the account is deemed by the state to be abandoned
property and is turned over to the state). That's why most bank
lobbies are much bigger than football stadiums, right?
>even explained to some of them that they will completely miss the viewer
that has obtained a copy of their page from a corporate proxy (with of
course no access at all to their server), to no avail. They simply will not
understand. It's right up there with "N people have visited this site
since..." :-)

Just let them put their meaningless counters on their web sites. It does no
harm, providing, as you say, they are not telling their "clients" that it
has meaning.

I am frightened that you seem unable to understand such simple concepts.

You know, I think you should suggest to banks that they dont really know
if someone is there and should end all session based online banking.
Banks don't try to count the number of people online at a given
time. It's useless information. They do worry about the possibility
that someone walked away from their computer, leaving the session
open, so they put timeouts on sessions that are short enough to
deter misuse of an open session but long enough to not annoy real
customers still trying to use it. They really don't care whether
you looked at your bank balance, then opened another tab and are
looking at vacations that you can afford.
>Or they could do the SENSIBLE thing and ASSUME in many cases that the
fact that someone opened the session means that there is a HIGH
PROBABILITY that someone os THERE. Possibly implement a time out. Oh,
they do jus that.
The timeout is *NOT* for the purpose of counting sessions. And I'm
sure if they tried to put "visitor counts" in their financial
statements, their auditors would jump all over them.

Oh, yes, bank customers actually LOG IN, so figuring out a number
of unique customers is fairly easy: look at the number of unique
login identifiers used in any given hour.
Jul 15 '07 #20

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
3629
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
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...
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
1444
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
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
10604
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
10359
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
10101
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
9177
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
6870
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...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3837
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.