如何查看用户是否在网站上使用php和mysql驱动的数据库? [英] How to see if a user is online in a website with php and mysql driven databases?

查看:144
本文介绍了如何查看用户是否在网站上使用php和mysql驱动的数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个社群网站。用户将像往常一样登录和注销。

I'm building a community website. Users will login and logout as usually.

我使用属性status online / offline设置用户的状态。但是如果用户只是点击X按钮或断开连接,否则不退出登录?

I use the attribute status online/offline to set the user's status. But what if a user just clicks the X button or disconnects otherwise without logging out?

最近我的电脑崩溃,当我用笔记本电脑打开网站时,我无法登录,我不允许在两个地方登录。我去PHPMyAdmin,我看到我的状态仍然在线。有什么修复这个。

Lately my computer crashed, when I opened the site with my laptop I could not login because I don't allow login in two places. I go to PHPMyAdmin and I see my status still online. Is there any fix for this.

我试过last_time激活的东西,但是在电脑崩溃的情况下不工作!

I tried the last_time activitiy thing but that doesn't work in case of a computer crash! And there was nothing neither interactivity or refresh to update the table.

推荐答案

您不需要在线/离线标记,只需要保存最后活动时间。当显示用户状态时,如果最后活动时间小于现在+ 15分钟,则用户在线,否则离线。

You don't need the online/offline flag, you just need to save the last activitity time. When displaying the user status, if last activity time is less than now+15 minutes then user is online, offline otherwise.

这篇关于如何查看用户是否在网站上使用php和mysql驱动的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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