Symfony\Bundle\FrameworkBundle\Controller\Controller::isCsrfTokenValid PHP Method

isCsrfTokenValid() protected method

Checks the validity of a CSRF token.
protected isCsrfTokenValid ( string $id, string $token ) : boolean
$id string The id used when generating the token
$token string The actual token sent with the request that should be validated
return boolean
    protected function isCsrfTokenValid($id, $token)
    {
        if (!$this->container->has('security.csrf.token_manager')) {
            throw new \LogicException('CSRF protection is not enabled in your application.');
        }
        return $this->container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($id, $token));
    }

Usage Example

コード例 #1
0
 public function isCsrfTokenValid($id, $token)
 {
     return parent::isCsrfTokenValid($id, $token);
 }