Page 1 of 1

php/mysql show logged in

Posted: Thu Jan 15, 2004 5:57 pm
by linuxbox
hey there, i have recently created a login/registration script and on my admin screen i'd like to show "users currently logged in" along with what page they are viewing. i'm using sessions but not using session id's in the cookie or anything that auto logs a person back in. is there a way to show all sessions? i have no clue on how to show users currently logged in for admin purposes.

thanks.

Posted: Thu Jan 15, 2004 6:12 pm
by kettle_drum
Each time a user loads a page store in a database the page they loaded, the time, username, IP etc. Then you can just print this info on your page. Of course only keep one record per username.

When displaying the page you can then just call the info from the database where the last page loaded time is without a certain time out value - like 5 mins.

You can then also use this to see the last time a user was seen - which can help you if you ever need to remove inactive users from the site.

Posted: Thu Jan 15, 2004 6:18 pm
by Straterra
Then arises this simple problem : What if there are guests? How do I show people who aren't guests? 1 solution to this is to assign the guest a unique guest-only cookie. Then, use the quest's IP to assign uniqueness to it in the database. From there, it shouldn't be hard to tell how many guests you have on your site. ^_^

Posted: Thu Jan 15, 2004 6:23 pm
by kettle_drum
You can just add guests to the same database table, but set the username to NULL and then identify them by their IP. Then make sure to remove this record if the guest logs on and becomes a member.

Posted: Thu Jan 15, 2004 6:36 pm
by linuxbox
kettle_drum wrote:Each time a user loads a page store in a database the page they loaded, the time, username, IP etc. Then you can just print this info on your page. Of course only keep one record per username.

When displaying the page you can then just call the info from the database where the last page loaded time is without a certain time out value - like 5 mins.

You can then also use this to see the last time a user was seen - which can help you if you ever need to remove inactive users from the site.
NEVERMIND--i figured it out.. DOH.. create another table frigg'n DOH!
geez, what am i smok'n. must be crack.