PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > how to count logged users in php
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
how to count logged users in php

Réponse
 
LinkBack Outils de la discussion
Vieux 22/04/2008, 20h05   #1
snowinfo@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how to count logged users in php

Hi all,

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

any /code appreciated,

craig
  Réponse avec citation
Vieux 22/04/2008, 20h09   #2
venti
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

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 /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?

  Réponse avec citation
Vieux 22/04/2008, 20h14   #3
snowinfo@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.com> wrote:
> 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 /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
  Réponse avec citation
Vieux 22/04/2008, 20h25   #4
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

On Tue, 22 Apr 2008 21:14:13 +0200, <snowinfo@gmail.com> wrote:

> On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.com> wrote:
>> 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 /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
  Réponse avec citation
Vieux 22/04/2008, 20h35   #5
snowinfo@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

On 22 Apr, 20:25, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Tue, 22 Apr 2008 21:14:13 +0200, <snowi...@gmail.com> wrote:
> > On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.com> wrote:
> >> 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 /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,.... :-(
  Réponse avec citation
Vieux 22/04/2008, 20h36   #6
Claudio Corlatti
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

On 22 abr, 16:14, snowi...@gmail.com wrote:
> On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.com> wrote:
>
> > 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 /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 full

  Réponse avec citation
Vieux 22/04/2008, 20h37   #7
Claudio Corlatti
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

On 22 abr, 16:14, snowi...@gmail.com wrote:
> On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.com> wrote:
>
> > 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 /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 full

  Réponse avec citation
Vieux 22/04/2008, 20h50   #8
snowinfo@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to count logged users in php

On 22 Apr, 20:37, Claudio Corlatti <corla...@gmail.com> wrote:
> On 22 abr, 16:14, snowi...@gmail.com wrote:
>
>
>
> > On 22 Apr, 20:09, venti <timgreg...@shieldinvestmentgroup.com> wrote:

>
> > > 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 /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 full


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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h25.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17960 seconds with 16 queries