CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Show number of logged in users?

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 12/16/2007, 8:37 PM

Anyone got a snippet of code that will allow me to show the current number of logged in users?

Mysql/php

Thanks!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Aaron


Posts: 145
Posted: 01/03/2008, 10:12 AM

This would totally depend on your database structure. As users log in, you will have to set a flag in your database to indicate if the user is logged in or not. This in itself leads to the issue of, what happens if a user(s) do not logout? You will have to create some sort of auto-logout feature.

Anyway, assuming this has all been done, you can create a query to SELECT the COUNT of people where logged-in is equal to 1 (or true or whatever you use). Then display the record count.

I believe this has been addressed a few times in the forums.
View profile  Send private message
DonB
Posted: 01/08/2008, 10:28 AM

Most (if not all) implementations of this are simply a query of 'timestamp
>= some threshold' (e.g. 10 minutes ago) You update their timestamp in the
users table when they log in and on every page they access. And, yes, the
'number of logged in users' is only approximate, and a bit wasteful of
database resources as you are doing lots of relatively-pointless updates.

--
DonB

http://ccswiki.gotodon.net


"Aaron" <Aaron@forum.codecharge> wrote in message
news:5477d257099889@news.codecharge.com...
> This would totally depend on your database structure. As users log in, you
> will
> have to set a flag in your database to indicate if the user is logged in
> or not.
> This in itself leads to the issue of, what happens if a user(s) do not
> logout?
> You will have to create some sort of auto-logout feature.
>
> Anyway, assuming this has all been done, you can create a query to SELECT
> the
> COUNT of people where logged-in is equal to 1 (or true or whatever you
> use).
> Then display the record count.
>
> I believe this has been addressed a few times in the forums.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.