开发者

Page Session Countdown Timer

开发者 https://www.devze.com 2022-12-16 06:36 出处:网络
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 s开发者_开发知识库hows the

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 s开发者_开发知识库hows the user how many minutes:seconds till the session times out. Are there any good examples out there?


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消