Re: [PHP] Users Online?

2009-06-21 Thread Michael A. Peters

Paul M Foster wrote:

On Sat, Jun 20, 2009 at 01:33:52PM -0700, Chris Payne wrote:


Hi everyone,

I have a login system that allows a user to login to my control panel,
is there an easy way so that I can tell how many users / what users
are logged into my system?  What would I need to do to add this with
the minimum of hassle?  Would I just have to look at the sessions that
are currently active and if so, how?  I really want to add this
feature as it will help with creating a messaging system.


Doing this purely with sessions is impossible (well, nearly), since
sessions can't see each other.


Yeah - what I do, and why I mentioned database, my session database has 
a field for userid so that I can easily with a single query associate a 
userid with a session.


mysql describe php_sessions;
+--+--+--+-+-+---+
| Field| Type | Null | Key | Default | Extra |
+--+--+--+-+-+---+
| session_id   | varchar(32)  | NO   | PRI | |   |
| session_data | longtext | YES  | | NULL|   |
| dt_created   | int(11)  | NO   | | 0   |   |
| ip_created   | varchar(32)  | NO   | | |   |
| dt_modified  | int(11)  | NO   | | 0   |   |
| ip_modified  | varchar(32)  | NO   | | |   |
| userid   | mediumint(9) | NO   | | 0   |   |
| expires  | int(11)  | NO   | | 0   |   |
| expired  | tinyint(4)   | NO   | | 0   |   |
+--+--+--+-+-+---+

That's one of the advantages to using a database for sessions - you can 
tie all kinds of groovy information to the session_id that can then help 
with future forensics and stuff if needed, and instead of deleting a 
session when it expires, set the expired field so that you can keep 
expired sessions around for longer yet they aren't useable by a client.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online?

2009-06-21 Thread Nitsan Bin-Nun
Why all this mess for such a simple thing?

All you need is to allocate the last activity timestamp with userid in the
users table, add 'last_activity' column to the users table then update it
with every page load at the administration panel. Then all you need to do in
order to print out the current logged in users is to SELECT `username` FROM
`users` WHERE `last_activity`  time() - 60*15

60*15 means that users which had an activity during the last 15 minutes will
be shown as logged in ;)

This is the way I would do that if you have no session handling system.

HTH,
Nitsan

On Sun, Jun 21, 2009 at 10:10 AM, Michael A. Peters mpet...@mac.com wrote:

 Paul M Foster wrote:

 On Sat, Jun 20, 2009 at 01:33:52PM -0700, Chris Payne wrote:

  Hi everyone,

 I have a login system that allows a user to login to my control panel,
 is there an easy way so that I can tell how many users / what users
 are logged into my system?  What would I need to do to add this with
 the minimum of hassle?  Would I just have to look at the sessions that
 are currently active and if so, how?  I really want to add this
 feature as it will help with creating a messaging system.


 Doing this purely with sessions is impossible (well, nearly), since
 sessions can't see each other.


 Yeah - what I do, and why I mentioned database, my session database has a
 field for userid so that I can easily with a single query associate a userid
 with a session.

 mysql describe php_sessions;
 +--+--+--+-+-+---+
 | Field| Type | Null | Key | Default | Extra |
 +--+--+--+-+-+---+
 | session_id   | varchar(32)  | NO   | PRI | |   |
 | session_data | longtext | YES  | | NULL|   |
 | dt_created   | int(11)  | NO   | | 0   |   |
 | ip_created   | varchar(32)  | NO   | | |   |
 | dt_modified  | int(11)  | NO   | | 0   |   |
 | ip_modified  | varchar(32)  | NO   | | |   |
 | userid   | mediumint(9) | NO   | | 0   |   |
 | expires  | int(11)  | NO   | | 0   |   |
 | expired  | tinyint(4)   | NO   | | 0   |   |
 +--+--+--+-+-+---+

 That's one of the advantages to using a database for sessions - you can tie
 all kinds of groovy information to the session_id that can then help with
 future forensics and stuff if needed, and instead of deleting a session when
 it expires, set the expired field so that you can keep expired sessions
 around for longer yet they aren't useable by a client.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Users Online?

2009-06-20 Thread Chris Payne
Hi everyone,

I have a login system that allows a user to login to my control panel,
is there an easy way so that I can tell how many users / what users
are logged into my system?  What would I need to do to add this with
the minimum of hassle?  Would I just have to look at the sessions that
are currently active and if so, how?  I really want to add this
feature as it will help with creating a messaging system.

It might be simple but if you've never done it before it's the hardest
thing in the world :-)

Thank you

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online?

2009-06-20 Thread Michael A. Peters

Chris Payne wrote:

Hi everyone,

I have a login system that allows a user to login to my control panel,
is there an easy way so that I can tell how many users / what users
are logged into my system?


I assume there is since many community applications (IE bulletin boards) 
show logged in users.


It's probably easiest if you use a database for session handling, but 
you can probably do it it other ways as well.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online?

2009-06-20 Thread Paul M Foster
On Sat, Jun 20, 2009 at 01:33:52PM -0700, Chris Payne wrote:

 Hi everyone,
 
 I have a login system that allows a user to login to my control panel,
 is there an easy way so that I can tell how many users / what users
 are logged into my system?  What would I need to do to add this with
 the minimum of hassle?  Would I just have to look at the sessions that
 are currently active and if so, how?  I really want to add this
 feature as it will help with creating a messaging system.

Doing this purely with sessions is impossible (well, nearly), since
sessions can't see each other. Your best bet is to add two fields to
your table(s)-- datetime logged in and datetime logged out. You'll need
to work out a way to expire someone's login if they appear to be logged
in too long (they closed their brower or left it open but forgot about
the tab for your site).

Upon login, you could perform a query of the table(s), looking for the
number of records where the logout field is empty.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Users Online?

2009-06-20 Thread David Swenson
Chris,

If it were me (and let me warn you, there's probably 100 different ways
to do this), but If I was using a table to log them into a control
panel (CP) of sorts, I'm sure you have other DB querries to handle the
CP stuff it self, correct?  Well if your already taking the time to
create a DB connection on each page of that CP, why not just make a
field that updates an active status, and/or add this to Pauls
suggestion of logged in/out times, then every page they visit updates
that time to show they are still active.  Then do something like my bank
does and set a time limit on each page, that if another page on the site
isn't visited in so many seconds, you force them to log out. (you could
even throw something in that asks the user if they want to stay logged
in, cuz that'd be a nice feature)  :)

Not sure if this was what you were lookin for but just an idea.

Best of luck,
David

-Original Message-
From: oxygene...@gmail.com [mailto:oxygene...@gmail.com] On Behalf Of
Chris Payne
Sent: Saturday, June 20, 2009 2:34 PM
To: php-general@lists.php.net
Subject: [PHP] Users Online?


Hi everyone,

I have a login system that allows a user to login to my control panel,
is there an easy way so that I can tell how many users / what users are
logged into my system?  What would I need to do to add this with the
minimum of hassle?  Would I just have to look at the sessions that are
currently active and if so, how?  I really want to add this feature as
it will help with creating a messaging system.

It might be simple but if you've never done it before it's the hardest
thing in the world :-)

Thank you

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.364 / Virus Database: 270.12.81/2189 - Release Date:
06/20/09 06:15:00



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] users online

2005-05-02 Thread Deep

Hi,

   Try this. I am assuming that you have already
fetched the name of the user who is online, either
from the database or from session or whatever. I am
assigning the variable $uname with that user online.
I've used javascript to display the name in the
textbox. Here goes the code. Simple.isn't it??


script language=JavaScript
function enterMe(who)
{
 document.frmpok.txtpok.value=who;
}

/script
?
$uname=David;
?
form name=frmpok action=#
input type=button name=butpok value=Enter
onclick=enterMe('? echo $uname;?');
input type=text name=txtpok value=
/form



--- Anasta [EMAIL PROTECTED] wrote:
 Hi, is this possible--
 I need a user (already logged in) to click on a
 button and his username
 shown in a text box next to it.
  This is for a chat and they need to be seated
 similar to poker game where
 they sit-in/sit out.
 
 Any help apreciated !
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] users online

2005-05-01 Thread Anasta
Hi, is this possible--
I need a user (already logged in) to click on a button and his username
shown in a text box next to it.
 This is for a chat and they need to be seated similar to poker game where
they sit-in/sit out.

Any help apreciated !

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] users online

2005-05-01 Thread Richard Lynch
On Sun, May 1, 2005 1:35 am, Anasta said:
 Hi, is this possible--
 I need a user (already logged in) to click on a button and his username
 shown in a text box next to it.
  This is for a chat and they need to be seated similar to poker game where
 they sit-in/sit out.

?php echo $name;?

What am I not getting here?...

Maybe you want it to happen on the CLIENT which wouldn't be PHP?...

FORM ACTION=# METHOD=GETINPUT TYPE=SUBMIT VALUE=Who Am I?
onClick=JavaScript:showname('?php echo $name;?'); return true;/FORM

Your showname function in JavaScript will probably have to use the
'innerHtml' value or something like that to alter the text you want to
change.  I forget exactly what it is, but this isn't a JavaScript list
anyway.



-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] users online

2005-04-03 Thread Ryan A
Hi,
I have been searching the archives with little luck so I need a reminder
here,
I remember a little while ago someone asked how  to implement the users
online functionality
that some sites have...now i have been asked to do exactly that but with a
small twist:
instead of displaying xx number of users online they want me to display
all the usernames who are online
with a link to their profile.

I have a few ideas on how this can be done, but I would like advise from
people who have already done this
or thought of doing it (i think there was also a class that does something
like this i'll check while waiting for a reply from you guys) so i can
compare it with my ideas (which are in the infancy stage ;-)  )

Thanks,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.1 - Release Date: 4/1/2005

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] users online

2005-04-03 Thread Ewout de Boer
Ryan A schreef:
 Hi,
 I have been searching the archives with little luck so I need a reminder
 here,
 I remember a little while ago someone asked how  to implement the users
 online functionality
 that some sites have...now i have been asked to do exactly that but with a
 small twist:
 instead of displaying xx number of users online they want me to display
 all the usernames who are online
 with a link to their profile.
 
 I have a few ideas on how this can be done, but I would like advise from
 people who have already done this
 or thought of doing it (i think there was also a class that does something
 like this i'll check while waiting for a reply from you guys) so i can
 compare it with my ideas (which are in the infancy stage ;-)  )

Easiest way of doing this is adding a 'last seen' field to your user
profiles and updating that record with the current timestamp every time
the user requests a page.

Al you need to do when displaying the 'users online' info is getting al
profiles with the 'last seen' record on a time between now and x minutes
ago (depending on what you consider to be an 'online' user).

If you're using a database like mysql or postgresql for profile storage,
use a field type that the database software can handle internaly, this
can speed up the query.


regards,
Ewout

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Users Online

2003-09-24 Thread Matias Hohl
Hello php-Freaks
I would like to display the number of users that are online on my page.
Scripting that is not the problem... but how can I refresh this number all 2
minutes on a users page?
I don't want to make always a redirect.  Isn't the a possibility like
streaming? :-)

Greetings,
Matias from Switzerland

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online

2003-09-24 Thread Becoming Digital
Do your users have to logon?  If so, run a count of logged-in users every 2min and use 
an IFRAME or Flash movie so that the rest of the page is unaffected.

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message - 
From: Matias Hohl [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, 24 September, 2003 08:36
Subject: [PHP] Users Online


Hello php-Freaks
I would like to display the number of users that are online on my page.
Scripting that is not the problem... but how can I refresh this number all 2
minutes on a users page?
I don't want to make always a redirect.  Isn't the a possibility like
streaming? :-)

Greetings,
Matias from Switzerland

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Users Online

2003-09-24 Thread Jay Blanchard
[snip]
Hello php-Freaks
I would like to display the number of users that are online on my page.
Scripting that is not the problem... but how can I refresh this number
all 2
minutes on a users page?
I don't want to make always a redirect.  Isn't the a possibility like
streaming? :-)
[/snip]

Place a small iframe on the page containing the information and then
refresh only the iframe.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online

2003-09-24 Thread Matias Hohl
No, they don't have to login. Does the Netscape Navigator know the
IFRAME-Tag? Can I read values from a DB with Flash?

Thanx

Becoming Digital [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
Do your users have to logon?  If so, run a count of logged-in users every
2min and use an IFRAME or Flash movie so that the rest of the page is
unaffected.

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message -
From: Matias Hohl [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, 24 September, 2003 08:36
Subject: [PHP] Users Online


Hello php-Freaks
I would like to display the number of users that are online on my page.
Scripting that is not the problem... but how can I refresh this number all 2
minutes on a users page?
I don't want to make always a redirect.  Isn't the a possibility like
streaming? :-)

Greetings,
Matias from Switzerland

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online

2003-09-24 Thread Matias Hohl
Ok, thanx. I think this is the best way to get a clean result.
But do all the Browsers know the IFRAME-Tag?

Jay Blanchard [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
[snip]
Hello php-Freaks
I would like to display the number of users that are online on my page.
Scripting that is not the problem... but how can I refresh this number
all 2
minutes on a users page?
I don't want to make always a redirect.  Isn't the a possibility like
streaming? :-)
[/snip]

Place a small iframe on the page containing the information and then
refresh only the iframe.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Users Online

2003-09-24 Thread Becoming Digital
Since the release of Flash MX, using Flash for data-driven applications is actually 
quite easy.  You can find a number of tutorials on DevShed regarding integration with 
PHP, all of which should prove helpful.

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message - 
From: Matias Hohl [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, 24 September, 2003 08:54
Subject: Re: [PHP] Users Online


No, they don't have to login. Does the Netscape Navigator know the
IFRAME-Tag? Can I read values from a DB with Flash?

Thanx

Becoming Digital [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
Do your users have to logon?  If so, run a count of logged-in users every
2min and use an IFRAME or Flash movie so that the rest of the page is
unaffected.

Edward Dudlik
Becoming Digital
www.becomingdigital.com



- Original Message -
From: Matias Hohl [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, 24 September, 2003 08:36
Subject: [PHP] Users Online


Hello php-Freaks
I would like to display the number of users that are online on my page.
Scripting that is not the problem... but how can I refresh this number all 2
minutes on a users page?
I don't want to make always a redirect.  Isn't the a possibility like
streaming? :-)

Greetings,
Matias from Switzerland

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php