I have this code in Laravel that I would like to translate to Trongate.
Would like to display all users currently logged in.
I'm open to other methods.
Thanks
How to handle users online
4 years ago
4 years ago
#1
4 years ago
#2
Are you using a members module or just Trongate users?
4 years ago
#3
Hello, I am using both the members module and the trongate_users module.
I googled around and did find a mysql version, but that would require a DB hit for each user per request.
I googled around and did find a mysql version, but that would require a DB hit for each user per request.
4 years ago
#4
This may work instead of using mysql
4 years ago
#5
final code
4 years ago
#6
Hello Frocco,
You can add 1 column to the Members Table,
online and offline
Use Boolean
User logs in set value to true
User logs out set value to false
The query the db for true
Dan
You can add 1 column to the Members Table,
online and offline
Use Boolean
User logs in set value to true
User logs out set value to false
The query the db for true
Dan
4 years ago
#7
That's another option, but what happens if they just close the browser?
4 years ago
#8
Hi frocco,
I'm not a Laravel user, so please excuse my ignorance.
Your handle($request, Closure, $next) method checks if a user is logged in > if so, adds 1 minute to now() time, then saves a line of serialised text to a file on your server (provided you are using Laravel's default 'file cache driver', and not Memcached/ Redis or DynamoDB) > then returns with the next request.
As you suggested, using sessions may meet your needs or writing to a file as above; for me I like your final code
data from your final code:
Well done! - give yourself a tick ?
I'm not a Laravel user, so please excuse my ignorance.
Your handle($request, Closure, $next) method checks if a user is logged in > if so, adds 1 minute to now() time, then saves a line of serialised text to a file on your server (provided you are using Laravel's default 'file cache driver', and not Memcached/ Redis or DynamoDB) > then returns with the next request.
As you suggested, using sessions may meet your needs or writing to a file as above; for me I like your final code
data from your final code:
Well done! - give yourself a tick ?
4 years ago
#9
Thank you Dafa, just wanted to share in case others were in need.
DaFa, I am trying to get away from Laravel, I have one ecommerce site which I am trying to convert to Trongate.
DaFa, I am trying to get away from Laravel, I have one ecommerce site which I am trying to convert to Trongate.
4 years ago
#10
Updated version