php - How count online users without using database?
问题描述
here is the code which I'm using to count online users but this is not working properly this count just 1 user every time. If that user is offline then this shows 0 users online. Please help why not this code working properly.
defined('MAX_IDLE_TIME') or define('MAX_IDLE_TIME', 10);
class online {
public static function who() {
$path = session_save_path();
if (trim($path)=="") {
return FALSE;
}
$d = dir( $path); $i = 0;
while (false !== ($entry = $d->read())) {
if ($entry!="." and $entry!="..") {
if (time()- filemtime($path."/$entry") < MAX_IDLE_TIME * 10) {
$i++;
}
}
}
$d->close();
return $i;
}
}
解决方案
推荐阅读
- google-fit - Google fit - 通过 SessionApi 找不到自动活动
- sql-server - 促销及其类型的数据库设计
- css - 如何在 Angular 6 中更改按钮状态?
- python - 如何默默地忽略日期时间解析失败?
- knockout.js - Magento 2中的英语到阿拉伯语
- matlab - Matlab直方图:连接bin中心
- google-analytics - Measurement Protocol 事件未在一个媒体资源中显示,而在其他媒体资源中却显示
- r - R Studio editData errormsg = object 'datatables html' not found
- javascript - 有没有比 crypto.randomBytes 更好的方法来生成性能方面的唯一 ID?
- batch-file - 您可以将条目从批处理文件添加到命令行历史记录吗?