Show all users online in Laravel 5.4

0

I'm wanting to show all the users currently connected and I came up with the following way, which I do not know if it's the right one.

First I detect the event when the user logs in and redis sets a session variable:

Redis::set('user:id:' . $event->user->id, json_encode($event->user));

then I then have to compare for each user if there is for example user 42. Redis :: get ('user: id: 42').

and when it logs off I detect that event and delete that user

 Redis::del('user:id:' . $event->user->id);

I do not know if it's the right thing to do using redis or using database for the sessions, or there is some other way to do this.

    
asked by Juan Pablo B 16.06.2017 в 15:08
source

0 answers