简体   繁体   English

使用Laravel 4获取在线用户

[英]Get online users with Laravel 4

I am trying to get online users count in Laravel 4. I am using Sentry 2 with Laravel. 我正在尝试让Laravel 4中的在线用户计数。我在Laravel中使用Sentry 2。 There are 2 columns in users table which are last_login and updated_at. 用户表中有2列,分别是last_login和Updated_at。 I am confused at this point, because everytime last_login and updated_at columns have same value. 在这一点上,我感到困惑,因为每次last_login和updated_at列都具有相同的值。 How do i set new update value in which user operation, even page reload? 如何设置用户操作甚至页面重新加载的新更新值? If it so i can calculate the time between last_login and updated_at, so i can see online users easly. 如果可以的话,我可以计算last_login和updated_at之间的时间,因此我可以轻松地看到在线用户。

Or is there an easy way to find online users in Laravel? 还是有一种简单的方法可以在Laravel中找到在线用户?

Thanks for helping. 感谢您的帮助。

Personally I would go with the suggestion from this link: 我个人会接受来自此链接的建议:

https://stackoverflow.com/a/4073355/3353724 https://stackoverflow.com/a/4073355/3353724

In laravel, I would do this: 在laravel中,我会这样做:

  1. Add 'last_seen' column in users table 在用户表中添加“ last_seen”列
  2. In App::before filter, add a logic to update the 'last_seen' column if user is logged in. 在App :: before过滤器中,如果用户已登录,请添加逻辑以更新“ last_seen”列。
  3. To check for online user, check if current time minus "last seen"-time is greater than some threshold you like. 要检查在线用户,请检查当前时间减去“上次看到”的时间是否大于您喜欢的某个阈值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM