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!
精彩评论