July 31st, 2000, 03:58 PM
Any suggestions on how to implement a feature in PHP/MySQL that will list the names of all users who are currently visiting a page (in this case, a PHP-based forum)? Each user either has a cookie (in which case their nick should be listed) or doesn't (in which case they should be listed as a guest).
July 31st, 2000, 04:15 PM
I would just take my user auth table, and add a field of "online". Then when you actually authenticate, update that field with a 1 and when they log off update it with a 0, and the you can just do a SELECT from the table to find all that have a 1 in the online field.
July 31st, 2000, 04:21 PM
Actually that will only work if you have them authenticating to even view the forum, other wise you will have to assign a cookie when they register, and do the same with the table and update the cookie when you update the table, if you know any perl, you might go to http://www.ubbhackers.com/cgi/Ultimate.cgi and search around there, I am sure they had a hack for the UBB to do that exact thing.
August 1st, 2000, 02:51 AM
Maybe you could do a separate table in your database, and when the user is on any of your pages the cookie is sent to that table, and the results of the table are displayed in the place where you want people to know who is online.
The problem with any solution though is that most users don't log off.
August 1st, 2000, 11:25 AM
Pretty complex solution, but one that's not dependent on logout.
When somebody 1st gets to the forums, set a cookie with there username, or guest if they've not posted anything yet. Then every time they hit a page, send the unixtime to a table next to the person's name in a table. Then when you load the who's online page, just query the database for anybody that's been on in the last 5 min or so (or 30 seconds.. whatever). This would be allot of mysql inserts and updates to update a table every time a page is displayed, but PHP forums usually do that anyway.
Just a thought.