php自动注销空闲超时

php自动注销空闲超时

本文介绍了使用jquery php自动注销空闲超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索并找到一些使用jquery设置空闲超时的示例。

I searched and find some examples to set idle timeout using jquery.

1 -

2 -

3 - /

3 - Fire Event When User is Idle / DEMO HERE

4 -

5 -

6 -

...以及其他几个类似的例子

... And several other similar examples

在这些例子中,数字1对于我需要更好,因为我需要在X分钟(logout.php或任何网址)后自动注销用户以及任何确认警报。但这种方法不适合服务器。问题是:这个jquery代码发送ping到任何url:keepAlive.php in loop / pooling for request OK text。见firebug屏幕:

Between these examples number 1 is better for i need because i need to auto logout user with any confirm alert after X minutes (logout.php or any url). but this method Not suitable for server. problem is : this jquery code send ping to any url : keepAlive.php in loop/pooling for request OK text . see firebug screen :

如何解决这个问题?
所以,其他示例只打印Idle / No Idle而不使用alert confirm和auto logout(logout.php或任何url)现在用jquery / Php选择空闲超时的方法真的更好吗?

how to fix this ?So, other examples only printed Idle/No Idle and not work with alert confirm and auto logout ( logout.php or any url ) now really better way to choose idle timeout using jquery/Php ?

谢谢

推荐答案

我在头部使用元刷新元素在X秒后自动将用户引导到注销页面的部分。下面将在停留在同一页面20分钟后自动将用户发送到注销页面:

I use a meta refresh element in the head section to auto-direct users to the logout page after X number of seconds. Below will automatically send a user to the logout page after 20 minutes of staying on the same page:

<meta http-equiv="refresh" content = "1200; url=http://www.site.com/user/logout">

这是有效的,(主要)支持跨浏览器,不依赖于JavaScript被启用,是非常容易实现。

This works, is (mostly) supported cross-browser, does not rely on JavaScript being enabled and is pretty easy to implement.

如果您的网站有长时间停留在同一页面上的用户(例如通过JS进行交互),此解决方案不适合你。在重定向发生之前,它也不允许运行任何JS代码。

If your site has users that stay on the same page for extended periods of time (with interaction taking place through JS, for instance), this solution will not work for you. It also does not allow any JS code to be run before redirection takes place.

这篇关于使用jquery php自动注销空闲超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:20