在网页上检查用户状态(活动,空闲) [英] checking user status (active, idle) on a web page

查看:162
本文介绍了在网页上检查用户状态(活动,空闲)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查用户状态 - 不管他是主动或闲置 - 在网页中(在弹出窗口)。如果他的空闲时间超过30分钟时,窗口会自动关闭,并在数据库中重置某些标志。

i am checking on the user status - whether he is active or idle - in a web page (in a pop up window). in case he is idle for more than 30 minutes, the window will automatically close and reset some flags in the database.

我,其中包含了时间的(他打开时弹出窗口)饼干,每一次检查对当前时间的页面刷新,否则他导航到另一个页面(仍然在弹出窗口中)。除了饼干,我还设置时间在数据库(在弹出窗口未打开,计划作业会照顾标志的复位的通过检查时间中在数据库中)。

i set cookies containing the time-in (the time he opens the pop-up window) and check it against the current time every time the page refreshes or he navigates to another page (still in the pop-up window). aside from the cookies, i also set the time-in in the database (in case the pop-up window isn't open, a cron job will take care of the resetting of flags by checking the time-in in the database).

有可能是他打字的东西,在窗口的情况下,没有页面加载发生在30分钟内使该窗口会自动关闭,他将失去他的工作。所以我增加了一个功能,使每一个的的onkeydown 的onclick 的事件,在这两个Cookie,并在数据库中的时间价值将被更新。

there might be a case that he is typing something in the window and no page load occurs within 30 minutes so the window will automatically close and he will lose his work. so i added a function so that each onkeydown and onclick event, the time-in value in both the cookie and the database will be updated.

也,可以有一个以上的谁正在使用该系统的人

also, there can be more than one person who is using the system.

这将消耗过多的资源?我不熟悉的东西,与此相关的问题。还是有更好的方法来做到这一点?

will this consume too many resources? i'm not familiar with stuff related to this issue. or is there a better way to do this?

谢谢!

推荐答案

如果您发送过onkey preSS和每一个onclick事件到服务器/数据库,这会穿透你的服务器! 对于这两件事情我想补充另一个JavaScript函数,它发送信息,如果用户是活跃的区间 - 例如 - 2分钟或5分钟。 您可以通过的setInterval或setTimeout的功能做到这一点,并跟踪,如果用户在上期表现活跃。 如果他是,发送请求,如果没有,不发送。

If you send ever onkeypress and every onclick event to the server/database, this will penetrate your server! For these two things I would add another javascript function which sends information if the user is active in an interval of - for example - 2 or 5 minutes. You can do this by setInterval or setTimeout functions and track, if the user was active in the last period. If he was, send the request, if not, don't send.

这篇关于在网页上检查用户状态(活动,空闲)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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