检测在线用户? [英] Detect online users?

查看:73
本文介绍了检测在线用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定什么是最简单的方法.我需要能够检测到哪些用户在我的网站上在线.因此,当人们查看线程或其他内容时,如果他们是在线或离线,它将在用户名旁边显示.在论坛索引的底部,它将说出所有在线用户.

I'm not sure what would be the easiest way to do this. I need to be able to detect what users are online on my website. So when people are viewing a thread or something it will say next to the users name if they are ONLINE or OFFLINE. And at bottom of forum index it will say all the users who are online.

做这样的事情最简单的方法是什么?我不确定是否需要在页面每次加载或每次加载时都可以运行的Javascript.

What would be the easiest approach to do something like this? I'm not sure if I will need a Javascript which would run every time a page loads or what.

谢谢:)

推荐答案

  • 拥有一个带有用户表的MySQL数据库
  • 该用户表中有一列,用于保存最后一次看到"的时间
  • 在每个页面请求上更新该列
  • 在检查在线或离线时,请检查当前时间减去上次看到"的时间是否大于您喜欢的某个阈值
  • 您可以选择每隔两分钟左右用一个javascript对服务器进行"ping"操作(请求一个空白页),如果您希望使闲置在您网站上的人也显示为在线.

    You could optionally make a javascript "ping" the server (request an empty page) every two minutes or so if you want people idling with your Website open to be displayed as online, too.

    这篇关于检测在线用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆