#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    14
    Rep Power
    0
    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).
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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.

    Chris
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    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.

    Chris
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    17
    Rep Power
    0
    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.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    15
    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.

Similar Threads

  1. Replies: 11
    Last Post: February 21st, 2004, 06:48 AM
  2. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM
  3. users create web page
    By chm0d in forum Apache Development
    Replies: 2
    Last Post: February 5th, 2004, 10:49 AM
  4. Replies: 2
    Last Post: February 4th, 2004, 11:10 PM
  5. passing the url from HTML page to a php
    By lordorkus in forum PHP Development
    Replies: 10
    Last Post: January 20th, 2004, 05:36 PM

IMN logo majestic logo threadwatch logo seochat tools logo