flextype-components / token
Simple Token Class
v1.2.0
2018-07-05 12:27 UTC
Requires
- php: ^7.1.3
- flextype-components/session: *
This package is auto-updated.
Last update: 2024-10-25 10:59:16 UTC
README
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