473,320 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to count logged users in php

Hi all,

any way to count the number of users i have logged into my site?

any help/code appreciated,

craig
Jun 2 '08 #1
13 6695
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?

Jun 2 '08 #2
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig

Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

That kinda thing

Cheers
Jun 2 '08 #3
On Tue, 22 Apr 2008 21:14:13 +0200, <sn******@gmail.comwrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
>On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig

Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?

I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.
1) Preferably use a database, have a table active_users
2) On each request with a session & logged in user, either insert a record
with the user-id with a timestamp (or datetime) field, with the current
time, or update an allready existing record with that information (if
MySQL: ON DUPLICATE KEY UPDATE saves a lot of hassle).
3) On checking for active users, remove all entries from the active_users
table with updated more than X minutes ago (X is your choice).
4) Display the list in active users.

1-3 are even easier (and more reliable) if you've taken to storing
sessions in the database with a custom handler using
session_set_save_handler(), but if you don't do this allready for other
reasons that would be a bit over the top for only an 'active users' script.
--
Rik Wasmus
Jun 2 '08 #4
On 22 Apr, 20:25, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Tue, 22 Apr 2008 21:14:13 +0200, <snowi...@gmail.comwrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

1) Preferably use a database, have a table active_users
2) On each request with a session & logged in user, either insert a record
with the user-id with a timestamp (or datetime) field, with the current
time, or update an allready existing record with that information (if
MySQL: ON DUPLICATE KEY UPDATE saves a lot of hassle).
3) On checking for active users, remove all entries from the active_users
table with updated more than X minutes ago (X is your choice).
4) Display the list in active users.

1-3 are even easier (and more reliable) if you've taken to storing
sessions in the database with a custom handler using
session_set_save_handler(), but if you don't do this allready for other
reasons that would be a bit over the top for only an 'active users' script.
--
Rik Wasmus
thanks for that

not sure how to write that though,.... :-(
Jun 2 '08 #5
On 22 abr, 16:14, snowi...@gmail.com wrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?

I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

That kinda thing

Cheers
i'm just thinking
you should add a field in the users table with the "last activity"
timestamp, each time the user clicks on a link you will update this
field.
Then you can establish a period of time that you consider the user
online and doing a simple select with that criteria you are going to
get the number of users online

hope it was helpfull

Jun 2 '08 #6
On 22 abr, 16:14, snowi...@gmail.com wrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?

I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

That kinda thing

Cheers
i'm just thinking
you should add a field in the users table with the "last activity"
timestamp, each time the user clicks on a link you will update this
field.
Then you can establish a period of time that you consider the user
online and doing a simple select with that criteria you are going to
get the number of users online

hope it was helpfull

Jun 2 '08 #7
On 22 Apr, 20:37, Claudio Corlatti <corla...@gmail.comwrote:
On 22 abr, 16:14, snowi...@gmail.com wrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.
That kinda thing
Cheers

i'm just thinking
you should add a field in the users table with the "last activity"
timestamp, each time the user clicks on a link you will update this
field.
Then you can establish a period of time that you consider the user
online and doing a simple select with that criteria you are going to
get the number of users online

hope it was helpfull
Thanks for the comments, but i'm not that good in php yet.
I can read more than i can write,

Anyone got a good tutorial or code i can use?

many Thanks
Crai
Jun 2 '08 #8
On 22 abr, 16:50, snowi...@gmail.com wrote:
On 22 Apr, 20:37, Claudio Corlatti <corla...@gmail.comwrote:
On 22 abr, 16:14, snowi...@gmail.com wrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.
That kinda thing
Cheers
i'm just thinking
you should add a field in the users table with the "last activity"
timestamp, each time the user clicks on a link you will update this
field.
Then you can establish a period of time that you consider the user
online and doing a simple select with that criteria you are going to
get the number of users online
hope it was helpfull

Thanks for the comments, but i'm not that good in php yet.
I can read more than i can write,

Anyone got a good tutorial or code i can use?

many Thanks
Crai
oh i'm sorry, i didn't see your previous reply
might this http://elouai.com/users.php will help you
it isn't for logged users, it counts users for ip, so maybe you have
to modify some things to adapt to your page

*sorry about my english ;O)
Jun 2 '08 #9
On 22 abr, 16:50, snowi...@gmail.com wrote:
On 22 Apr, 20:37, Claudio Corlatti <corla...@gmail.comwrote:
On 22 abr, 16:14, snowi...@gmail.com wrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.
That kinda thing
Cheers
i'm just thinking
you should add a field in the users table with the "last activity"
timestamp, each time the user clicks on a link you will update this
field.
Then you can establish a period of time that you consider the user
online and doing a simple select with that criteria you are going to
get the number of users online
hope it was helpfull

Thanks for the comments, but i'm not that good in php yet.
I can read more than i can write,

Anyone got a good tutorial or code i can use?

many Thanks
Crai
oh i'm sorry, i didn't see your previous reply
might this http://elouai.com/users.php will help you
it isn't for logged users, it counts users for ip, so maybe you have
to modify some things to adapt to your page

*sorry about my english ;O)
Jun 2 '08 #10
On 22 abr, 16:14, snowi...@gmail.com wrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?

I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

That kinda thing

Cheers
i'm just thinking
you should add a field in the users table with the "last activity"
timestamp, each time the user clicks on a link you will update this
field.
Then you can establish a period of time that you consider the user
online and doing a simple select with that criteria you are going to
get the number of users online

hope it was helpfull

Jun 2 '08 #11
On 22 Apr, 20:25, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Tue, 22 Apr 2008 21:14:13 +0200, <snowi...@gmail.comwrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have hit
your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

1) Preferably use a database, have a table active_users
2) On each request with a session & logged in user, either insert a record
with the user-id with a timestamp (or datetime) field, with the current
time, or update an allready existing record with that information (if
MySQL: ON DUPLICATE KEY UPDATE saves a lot of hassle).
3) On checking for active users, remove all entries from the active_users
table with updated more than X minutes ago (X is your choice).
4) Display the list in active users.

1-3 are even easier (and more reliable) if you've taken to storing
sessions in the database with a custom handler using
session_set_save_handler(), but if you don't do this allready for other
reasons that would be a bit over the top for only an 'active users' script.
--
Rik Wasmus
.....or just use a database bound session handler and reverse-engineer
how to get a count of sessions.

C.
Jun 2 '08 #13
On Wed, 23 Apr 2008 14:00:17 +0200, C. (http://symcbean.blogspot.com/)
<co************@gmail.comwrote:
On 22 Apr, 20:25, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
>On Tue, 22 Apr 2008 21:14:13 +0200, <snowi...@gmail.comwrote:
On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.comwrote:
On Apr 22, 3:05 pm, snowi...@gmail.com wrote:
Hi all,
any way to count the number of users i have logged into my site?
any help/code appreciated,
craig
>Do you actually have people authenticating with usernames/passwords,
or are you just looking to see how many people (unique users) have
hit
>your site?
I have them logging in first, set by a session, so I just want to say
'There are X users logged in' and then list the usernames.

1) Preferably use a database, have a table active_users
2) On each request with a session & logged in user, either insert a
record
with the user-id with a timestamp (or datetime) field, with the current
time, or update an allready existing record with that information (if
MySQL: ON DUPLICATE KEY UPDATE saves a lot of hassle).
3) On checking for active users, remove all entries from the
active_users
table with updated more than X minutes ago (X is your choice).
4) Display the list in active users.

1-3 are even easier (and more reliable) if you've taken to storing
sessions in the database with a custom handler using
session_set_save_handler(), but if you don't do this allready for other
reasons that would be a bit over the top for only an 'active users'
script.
....or just use a database bound session handler and reverse-engineer
how to get a count of sessions.
Which is exactly what I said with 1-3 being simpler when storing the
sessions in a database...
--
Rik Wasmus
Jun 2 '08 #14

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

Similar topics

4
by: vesely | last post by:
Hi all, I'm currently relying on logged-in users hitting "logout" (logoff) before they leave, in order to terminate the session. With PHP the session filename is in a cookie that lasts for the...
2
by: Daniel L. | last post by:
Hi, I've searched over 1 hour on Google and elsewhere and haven't found anything. I'd like to find a way to get the real active user count on our website. THe main problem I have is when a...
8
by: gil | last post by:
I'm trying to track how many users are visiting a site and how may are logged in, using application sessions like so: Sub Session_OnStart Session.Timeout = 20 Session("Start") = Now...
8
by: Mike Thomas | last post by:
I have two clients now who want to have an Access 2000 & 2002 application running on NT Server 2000 do some file updating at night when nobody is in the office. I have used Windows scheduler to...
6
by: KS | last post by:
I have made a WebForm with log ON/OFF off users. There is a label that shows the total count off users logged on stored in Application("UserCount") It works fine if the users logs out WITH THE...
1
by: Bar?? | last post by:
Hi, I want to show number of active users (login users) on my web page. Creating the number of activate users is easy. I increased an application variable (Application("numOfUsers")) by one when...
1
by: aps786 | last post by:
Hi, There is a table where I store ipaddress and user who logged in from that IP. I have a query to findout all ipaddresses, from where diff users had made request. stat ------------ ip...
32
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?
8
by: Mike P | last post by:
What would be the best way of counting the number of users who are currently logged on to a website? I am making the users login against a database of valid users. Would the best way be to add a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.