0

I'm building a Laravel website and I'm using the database driver to manage sessions. I created the sessions table in database and migrated with php artisan. Everything works as expected. What I really want to do now is to check the role of the users that are online but I don't know how to get this with the fields of the sessions table in the database. I don't really understand how the sessions table work, because I see that it registers a new row when I access to the login page, but it doesn't change when the user has logged in and when the user has logged out. All I wanted is to check the role of the users active in the app.... Someone can help me with how to get to this? Thank you!

1 Answers1

1

I suggest you a very simple way. Just in your users table add a field called "is_online" that is 0 by default. When the user logs in , just change it to 1 and when he logs out change it back to 0. So DB::table('users')->where('is_online' , 1)->all() returns the online users.

Peyman.H
  • 1,819
  • 1
  • 16
  • 26
  • thank you!! i'm going to do something very similar to this, in fact this was the easiest thing I could think on to solve my requirements. Thank you! –  Sep 02 '15 at 12:15
  • @aaleahya So glad to helped you! :) – Peyman.H Sep 02 '15 at 12:23