I am on the same page, I am developing a project on nights and weekends and may need help.
The goal is to become a startup and provide a service SaaS world wide.
Any adventurer that wants to join?
I did a different approach. I configure to use database sessions (mysql).
php artisan session:table php artisan migrate
Since the last_activity on sessions table is stored as epoch (Unix timestamp since 1970-1-1), we can query all the active sessions that are bigger than the current time stamp minus the session expire time.
// Get time session life time from config. $time = time() - (config('session.lifetime')*60); // Total login users (user can be log on 2 devices will show once.) $totalActiveUsers = sessions::where('last_activity','>=', $time)-> count(DB::raw('DISTINCT user_id')); // Total active sessions $totalActiveUsers = sessions::where('last_activity','>=', $time)-> get();
Hope this can help anyone.