it boils down to using a db table to store your user's sessions and then counting the row and reading the user id's stored in that session.
Thanks for the answer,but how can I read the user id from that session? It's a base64 encrypted data.
I have to keep a log in the DB of each page view for auditing, I can then utilise this to grab people who were online in say last 20 minutes
I was able so far to do the following: I created a new field in sessions table named user_id, then after user logs in, i ran the follow function:
//Sessions is an eloquent model for sessions table
$Session = Sessions::find(Session::getId());
$Session->user_id = Auth::user()->id;
$Session->save();
But I really think that should be a better way, by reading the actual session, but I doesn't found a way to do that.
I think that this should be possible using PusherJS in combination with Laravel. Take a look at this simple example,
That way you don't have to do a database insert on every login and PusherJS is responsible for handling presence channels.
Just save User_ID (I would save displayed name to) in session and select all sessions that have User_ID set and not older than X...
How would you save the User_ID to the sessions table? Do you need to extend /vendor/laravel/framework/src/Illuminate/Session/SessionManager.php?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community