页面会话倒计时器

发布于 2024-08-18 03:43:21 字数 99 浏览 4 评论 0原文

我编写了一段 PHP 代码,该代码在创建后 5 分钟后终止会话。

我想在页面的一角显示一个计时器,显示 用户距离会话超时还有多少分钟:秒。有没有什么好的 那里有例子吗?

I wrote a PHP code that kills the session after 5 minuets from creation.

I would like to display a timer in the corner of the page that shows the
user how many minutes:seconds till the session times out. Are there any good
examples out there?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落成白 2024-08-25 03:43:21

像这样的东西吗?
http://keith-wood.name/countdown.html

这里有一个简单的例子显示如何使用它:

var newYear = new Date(); 
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1); 
$('#defaultCountdown').countdown({until: newYear}); 

现在我们需要的是一个 UNIX 时间戳(会话结束的时间)。然后我们可以这样修改它:

var endOfSession = new Date(youtitmestamp * 1000); // timestamp is in seconds and we need miliseconds
$('#defaultCountdown').countdown({until: endOfSession}); 

希望它有帮助!

Something like this?
http://keith-wood.name/countdown.html

There you have a simple example showing how to use it:

var newYear = new Date(); 
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1); 
$('#defaultCountdown').countdown({until: newYear}); 

So now what we need is a UNIX timestamp (time when session will end). Then we can modify it like this:

var endOfSession = new Date(youtitmestamp * 1000); // timestamp is in seconds and we need miliseconds
$('#defaultCountdown').countdown({until: endOfSession}); 

Hope it helped!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文