Jump to content


This topic is now archived and is closed to further replies.


listing online users

Recommended Posts

I'm still quite new to PHP but threw myself into a bigger project, I'm trying to caode a forum.
I do realize that it's a big task, but I'm not that far from finishing it.

My problem is that I'd like to list the users that are online, much like this forum does, list logged in people, and visitors - but i have absolutely no idea how to do this.

Any help would be appreciated - a push in the right direction will suffice, though a solution with comments to explain how it work would be really nice :)

Share this post

Link to post
Share on other sites
As a start, might take a look here...

[a href=\"http://www.llstudios.net/directory/16-1\" target=\"_blank\"]http://www.llstudios.net/directory/16-1[/a]


Share this post

Link to post
Share on other sites

This is a not something that can be achive easily and quickly. You need to consider your designing and structure of your code.
There are many ways to achieve this, but this is within my experience:

1. a session table. This table have fields like this:
sessionid, ip, username, status, timestamp.

sessionid hold the session id of user
ip: hold the ip
username hold the username, if not found, put a value of 'guest'
timestamp: the time stamp of last accessing

you can add extra field like page url to store the current page user is viewing (last click).

2. on every page, put a session code. This code update the status of user and the time stamp based on session id. if sessionid not exist, create one. (This is where the complicated work done).

3. to display the user online, simply query the session table to find out.

that's it.
remember, those are just designing.

Share this post

Link to post
Share on other sites
oh yes, i forgot to mention this.

on step 3 when you read out session users, you will compare the timestamp in the table, against the current timestamp. If the difference was too large, i.e. idle time exceeded, delete this user.

and I just though of something else too. You do not need the status field. simply delete the user if he/she exceed the idle time.

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.