Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Display on website all users that are currently logged in!

Hi there,

I am wondering how to find and display all users that are currently logged into my website. How I display one name for the user that is logged in is simple. But how can I grab all users from my user database and display a list of the ones currently logged in.

Thank you.
0
james130c
Asked:
james130c
1 Solution
 
EyalCommented:
you will have to set some kind of application variable that will hold a list.
in session start and session end you will update this list
0
 
Andrew DerseIT ManagerCommented:
You would script something like this:

 
<?php

$query = msqyl_query("SELECT * FROM users");
while($row = mysql_fetch_array($query))
{
echo 'Username: ' . $row['username'] . '<br />';
}

?>

Open in new window


This will display a list of each username in the system.

Naturally you will want to limit it to just logged in users like you said so code this in there...change it accordingly to fit your database...

 
<?php

$query = msqyl_query("SELECT * FROM users where logged_in = 'true' ");
while($row = mysql_fetch_array($query))
{
echo 'Username: ' . $row['username'] . '<br />';
}

?>

Open in new window

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now