如何进行线上/线下 [英] How to make online/offline

查看:70
本文介绍了如何进行线上/线下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录系统.使用我的登录会话存储和 cookie(如果您还记得我"),然后您登录.当您在 home.php 的登录系统中时(您只能在 session/cookie 已注册的情况下输入),我希望用户"表中的状态字段在您注销时更新为在线和离线.

I have a login system. With my login session stores and cookies (if you "remember me") and then you login. When you're inside the login system at home.php (you can only enter if session/cookie is registered), i want the status field in "user" table, to update to online and offline when you sign out.

我知道如何执行此操作,以便在您登录和注销时更新状态,但问题是:当用户离开站点而未注销(按下实际的注销按钮)时,我该怎么办?我的意思是,如果状态设置为 Online 并且您离开该页面,它将保持在线状态,您可能会理解...逻辑...那么在这种情况下我该怎么办?我不想有一个丑陋的弹出窗口,当您离开页面时将您注销,这太老派了.

I know how to do this, to update the status when you login and log out, but here's the thing: How do i do when the user leaves the site without logging out (pressing on the actual log out button) ? I mean if the status is set to Online and you leave the page, it will remain Online you may understand..logic.. so what do i do at this situation? I don't want to have a little ugly popup that log you off when you leave the page, that's so old school and bad.

或者当会话用完时,您将状态设置为离线?但同样,我该怎么做?

Or maybe when the session runs out then you set the status to offline? but again, how should i do that?

有关解决方案的想法和示例会很好.

Ideas and examples on solution for this would be good.

像 facebook 这样的网站,在聊天中,如果您离开页面,您会将状态更改为空闲,如果您离开页面,一段时间后您将处于离线状态...怎么办,我不知道.

Sites like e.g facebook, in the Chat you change status to Idle if you leave the pages, and somehow if you leave the page and there goes some time you are offline... How, I don't know.

推荐答案

Facebook 有点讨厌,因为他们的页面包含一些 Javascript,可以保持与聊天服务器的开放连接.一旦失去连接,就意味着您已关闭页面(或您的互联网连接)并且您被标记为离线.

Facebook is a bit nasty in that their page contains some Javascript that keeps an open connection to their chat server. Once the connection is lost, it means you've closed the page (or your internet connection) and you're marked offline.

通常,只使用超时来标记用户在上次活动/页面加载后的一段时间内离线.例如,此超时的合理值可以是他们的会话 cookie 过期的时间.

Usually, just a timeout is used that marks the user offline some time after their last activity/page load. A reasonable value for this timeout could for instance be the time after which their session cookie expires.

这篇关于如何进行线上/线下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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