如何告诉用户他们已经自动注销? [英] How to tell user they have been automatically logged out?

查看:89
本文介绍了如何告诉用户他们已经自动注销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将这个用于非活动用户,那些在网站上没有活动的用户



使用此功能可以告诉用户会话已过期请登录再次?我的意思是一条友好的消息,例如你的会话已经过期,请再次登录。



I m currently using this for inactive users, those that are not been active on the site

Using this is it possible to tell the user session expired please login again? I mean a friendly message like " your session have expired please login again."

<meta http-equiv="refresh" content="600;url=logout.php" />

推荐答案

我想你的方法可能有用,你必须在每一页上都有。



通常这是使用JavaScript中的某种形式的计时器完成的。由于网络是一个断开连接的媒介,你必须在客户端有一些火,因此你使用JavaScript。



例如,你可以调用setTimeout(logoutFunction,sessionTimeInMilliseconds )。如果时间过去,则JavaScript会调用您的logoutFunction,然后您可以弹出消息或重定向或任何您想要的内容。



您也可以变得更加复杂。例如,通过从setTimeout的delay参数中减去10分钟,您可以在退出10分钟后显示消息。



这是一个如此常见的请求,我想知道是否有没有库来帮助它变得更容易。我建议使用谷歌搜索其他方法来处理这个问题。这并不难,但如果有人已经有一个干净且易于使用的插件,那就太好了。
I suppose your method may work and you'd have to have it on every page.

Usually this is done using some form of timers in JavaScript. Since the web is a disconnected medium you have to have something fire on the client side and therefore you use JavaScript.

For example, you can call setTimeout(logoutFunction, sessionTimeInMilliseconds). If the time passes then JavaScript will call your logoutFunction which you can then popup a message or redirect or whatever you want.

You can get more sophisticated too. For example, you can display a message when they are 10 minutes away from logout by subtracting 10 minutes from the delay parameter of setTimeout.

This is such a common request that I wonder if there are not libraries to help make it easier already. I'd suggest googling for other ways to handle this. It isn't hard to do but would be nice if someone has already got a nice clean and easy-to-use plugin.


这篇关于如何告诉用户他们已经自动注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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