2017-06-15 100 views
-6

锁定功能,我需要知道如何去实现这个想法在PHPPHP OOP如何从同一个用户

Add random sleep (max 30s) after validation, if it was successful to emulate some long running process. 
Do not allow to make bet for the same user until response is not returned to `Bet.php` calling class. 

If player tries to pass more than one request and his previuos is not finished yet, return appropriate 
`error_code` from the list provided. 

我认为,在我存储所有玩家不能让打赌我能创建列表,赌注我认为这是不好的和可选的。

也许我可以添加一些列的数据库表“用户”,如果玩家用或不

+0

你不需要为此的数据库。只是使用一个PHP会话(隐式cookie) – Phil

+2

太多的问题没有接受;这里的记录不是很好 –

回答

1

使用PHP-Session。开始会话以使用cookie跟踪用户,以便您可以决定用户是否第一次访问该网站。然后保存开始时间。

<?php 
session_start(); // start session to get access to $_SESSION and set an individual cookie for each user 

if(!isset($_SESSION['time'])) 
{ 
    $_SESSION['time'] = time(); 
    // start the timer 
} 
else 
{ 
    $difference = round(abs($_SESSION['time'] - time())/60,2); 

    if($difference < 30) 
    { 
     die('Your need to wait!'); 
    } 

    echo "The time is over."; 
}