v1.2.0 2018-07-05 12:27 UTC

README

version MIT License

The Token component generate and store a unique token which can be used to help prevent CSRF attacks.

Installation

composer require flextype-components/token

Usage

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
}

License

See LICENSE