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!
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.