Support the ongoing development of Laravel.io →
Authentication Session Database
Last updated 2 years ago.
0

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.

source http://laravel.com/docs/session#database-sessions

Last updated 2 years ago.
0

Thanks for the answer,but how can I read the user id from that session? It's a base64 encrypted data.

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Anyone?

Last updated 2 years ago.
0

I think that this should be possible using PusherJS in combination with Laravel. Take a look at this simple example,

simple php/pusherjs example

That way you don't have to do a database insert on every login and PusherJS is responsible for handling presence channels.

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

How would you save the User_ID to the sessions table? Do you need to extend /vendor/laravel/framework/src/Illuminate/Session/SessionManager.php?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.