-2

Does anyone has any idea how to show all the active logged in users of the session in php? I've tried

 <?php echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>'; ?>

but it only shows current user. How to show all the logged in users at once, just like the facebook shows?`

elixenide
  • 44,308
  • 16
  • 74
  • 100
  • If You are using `files` as session storage ( which is default option ) You can try to get user data from default session file - check this answer how to do this https://stackoverflow.com/questions/4698432/read-the-session-data-from-session-storage-file – Michal Przybylowicz Jun 08 '15 at 01:56

1 Answers1

3

$_SESSION only relates to the active session - one user. You need a database to track what sessions are active.

elixenide
  • 44,308
  • 16
  • 74
  • 100
  • yes, I have a database. How to track logged in users from there? @Ed Cottrell – Incredible Saurav Jun 08 '15 at 00:55
  • 1
    @IncredibleSaurav Unfortunately, that question is much too broad. We would need to know the relevant tables and columns in your database, as well as the relevant PHP code. Otherwise, there's no way for us to give a reasonable answer in a few paragraphs, as required by this site. – elixenide Jun 08 '15 at 00:59