public function checkToken(string $tokenToCheck): bool
    {
        //Throw Exception
        $tokenInfos = $this->obtainToken();

        $token      = $tokenInfos->token;
        $dateCreate = $tokenInfos->date;
        $timeExpire = $tokenInfos->expire;

        if ($token !== $tokenToCheck) {
            return false;
        }

        $limitDate = new DateTime;
        $limitDate->modify('-'.$timeExpire.' minutes');
        
        unset($_SESSION['formsTokens'][$this->formId]);
        
        if ($dateCreate < $limitDate) {
            return false;
        }

        return true;
    }
public function checkToken(string $tokenToCheck): bool
    {
        //Throw Exception
        $tokenInfos = $this->obtainToken();

        $token      = $tokenInfos->token;
        $dateCreate = $tokenInfos->date;
        $timeExpire = $tokenInfos->expire;

        if ($token !== $tokenToCheck) {
            return false;
        }

        $limitDate = new DateTime;
        $limitDate->modify('-'.$timeExpire.' minutes');
        
        unset($_SESSION['formsTokens'][$this->formId]);
        
        if ($dateCreate < $limitDate) {
            return false;
        }

        return true;
    }
public function checkToken ( string $ tokenToCheck ) : bool { //Throw Exception $ tokenInfos = $ this -> obtainToken ( ) ; $ token = $ tokenInfos -> token ; $ dateCreate = $ tokenInfos -> date ; $ timeExpire = $ tokenInfos -> expire ; if ( $ token !== $ tokenToCheck ) { return false ; } $ limitDate = new DateTime ; $ limitDate -> modify ( '-' . $ timeExpire . ' minutes' ) ; unset ( $ _SESSION [ 'formsTokens' ] [ $ this -> formId ] ) ; if ( $ dateCreate < $ limitDate ) { return false ; } return true ; }
Check the token receive with the generated token

@param string $tokenToCheck The token receive from user

@throws \Exception If the token not exist

@return boolean
Check the token receive with the generated token