For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2006 > counting users









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author counting users
Bruintje Beer

2005-11-20, 3:55 am

Hi,

Does somebody know how to count all active users in php logged in on your
website. How do you catch when a user leaves yur site and decrement the
login count.

John


Geoff Berrow

2005-11-20, 7:55 am

Message-ID: <438026bc$0$720$5fc3050@dreader2.news.tiscali.nl> from
Bruintje Beer contained the following:

>Does somebody know how to count all active users in php logged in on your
>website. How do you catch when a user leaves yur site and decrement the
>login count.


You can't. As http is stateless, the only way you know that people are
reading your pages is if they keep requesting them. When they stop you
can assume they are not.

You can count the number of people who have accessed your pages in the
last, say, five minutes, which may be good enough for your purposes.
Googling will provide examples of code.

--
Geoff Berrow 0110001001101100010000000110
0011011010110110010001101111011001110010
11
1001100011011011110010111001110101011010
11
Alain

2006-01-10, 4:00 am

Bruintje Beer wrote:

> Hi,
>
> Does somebody know how to count all active users in php logged in on your
> website. How do you catch when a user leaves yur site and decrement the
> login count.
>
> John
>
>

Hey there, that's not exactly what I'm looking for, but I'm tempted to
ask you then, how do the "meet the others" site know who is online ?
Michael Vilain

2006-01-10, 4:00 am

In article <43a91153$0$949$626a14ce@news.free.fr>, Alain <xxx@yyy.com>
wrote:

> Bruintje Beer wrote:
>
> Hey there, that's not exactly what I'm looking for, but I'm tempted to
> ask you then, how do the "meet the others" site know who is online ?


Since the server/browser model is stateless, there's no real way to do
this reliably. Once a user logs into a site and is given a session ID
and a time stamp (you have to do all of this), that's all you can really
track. You can check a time stamp on the session ID the next time they
access a page, but until they do, you don't know if they've "left" your
site, gone to get coffee or are just reading the text on the page.

--
DeeDee, don't press that button! DeeDee! NO! Dee...



Jim Michaels

2006-01-19, 6:58 pm

one way is to set up a login page and a table of users with a timestamp that
gets reset every time the user visits a page. if the timeout gets too long,
assume the user has left the site (assume a logout). this was suggested on
another post.
"Michael Vilain" <vilain@spamcop.net> wrote in message
news:vilain-6A7801.11404321122005@comcast.dca.giganews.com...
> In article <43a91153$0$949$626a14ce@news.free.fr>, Alain <xxx@yyy.com>
> wrote:
>
>
> Since the server/browser model is stateless, there's no real way to do
> this reliably. Once a user logs into a site and is given a session ID
> and a time stamp (you have to do all of this), that's all you can really
> track. You can check a time stamp on the session ID the next time they
> access a page, but until they do, you don't know if they've "left" your
> site, gone to get coffee or are just reading the text on the page.
>
> --
> DeeDee, don't press that button! DeeDee! NO! Dee...
>
>
>



Jim Michaels

2006-01-19, 6:58 pm

Oh yeah - counting the users would be as easy as counting all the users
whose timestamp os not older than a certain amount.

"Michael Vilain" <vilain@spamcop.net> wrote in message
news:vilain-6A7801.11404321122005@comcast.dca.giganews.com...
> In article <43a91153$0$949$626a14ce@news.free.fr>, Alain <xxx@yyy.com>
> wrote:
>
>
> Since the server/browser model is stateless, there's no real way to do
> this reliably. Once a user logs into a site and is given a session ID
> and a time stamp (you have to do all of this), that's all you can really
> track. You can check a time stamp on the session ID the next time they
> access a page, but until they do, you don't know if they've "left" your
> site, gone to get coffee or are just reading the text on the page.
>
> --
> DeeDee, don't press that button! DeeDee! NO! Dee...
>
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com