2010-03-11 5 views
0

는 내가 가지고 :PHP 초 카운트 다운

지금은 페이지로드에서 원하거나
<?php 
setcookie("game", "GOW2", time()+3); 
echo $_COOKIE["game"]."</br>"; 

echo "<a href=\"/mypro/mypro2.php/\">Refresh</a></br>"; 

?> 

사용자는 '새로 고침'은 다음과 같은 기능을 클릭 할 때

타이머가 다시 얻을해야하며 표시하세요 (이 카운트 다운은 0에 도달 할 때까지 계속됩니다.

이것은 할 수 있습니까 ??

+1

일부 자바 스크립트 기능으로 - 물론. 그건 그렇고, 나는 그런 쿠키가 어떤 것에도 유용 할 것 같은데 –

답변

0

안녕, 나는 SESSION이 아닌 쿠키를 사용하는 것이이 경우

. 동일하게 세션을 만듭니다.

<?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>"; 
?>