The Token component generate and store a unique token which can be used to help prevent CSRF attacks.
composer require flextype-components/token
Generate token
use Flextype\Component\Token\Token;
$token = Token::generate();
Generate token in the template
<?php use Flextype\Component\Token\Token; ?>
<input type="hidden" name="csrf" value="<?php echo Token::generate(); ?>">
Check that the given token matches the currently stored security token.
use Flextype\Component\Token\Token;
if (Token::check($token)) {
// Pass
}
See LICENSE