How to display Registered Users Online with php?

Hi Guys i have a register for and users can register.

then the database store all users.

how can i display all users online as it is in the bottom of this forum that dispaplys the users Username that are online?

thanks

You need somewhere to store a list of usernames and a timestamp (DB or a file).

On each page request:

  1. Insert (or update) the username of curently logged in user and current timestamp (last activity time).
  2. Remove all users whose timestamp is for example 5 minutes old.

That’s your list of currently logged in users.

once user loads a page, write down his username and time of activity.
Next, loop over this list, delete ones, who’s activity was 5 minutes ago and more, and display the rest.

can someone show me actually a script to get the idea.

i store all the usernames into a database table named "users_table"which “username” stores all the username.
i just want to display the users logged in.

Please follow basic rules when posting…

thanks:)