在我的php页面中,我有:
<?php
setcookie("game", "GOW2", time()+3);
echo $_COOKIE["game"]."</br>";
echo "<a href=\"/mypro/mypro2.php/\">Refresh</a></br>";
?>现在,我希望在页面加载时或当用户单击“刷新”时,具有以下功能
计时器应该被重置并显示(作为倒计时),这个倒计时一直持续到它达到0并停止。
这可以做到吗??
发布于 2010-03-11 14:32:47
哈罗,
在这种情况下,我将使用会话,而不是COOKIE。做同样的事情,但是要进行会话。
<?php
session_start();
if (!isset($_SESSION["game"])){
$_SESSION["game"] = time()+3;//+3 is the time to the end of countdown
}
//get the moment of execution the script
$now = time();
//calculate count down value
$countdownvalue = $now - $_SESSION["game"];
//display $countdown value
echo $countdownvalue."</br>";
echo "<a href=\"/mypro/mypro2.php/\">Refresh</a></br>";
?>https://stackoverflow.com/questions/2422872
复制相似问题