aryqs/csrf

This package is abandoned and no longer maintained. No replacement package was suggested.

Very simple csrf token verification for POST data

dev-master 2020-08-04 15:44 UTC

This package is not auto-updated.

Last update: 2021-11-24 20:20:34 UTC


README

This repository contain two simplified methods to store and verify tokens. It prevent all unsafe HTTP requests.

POST and SESSION variables are stored in '_token' values. This string can be changed in param of function

Install

via composer

$ composer require aryqs/csrf

Usage

use aryqs\csrf\Token;

require __DIR__ . '/vendor/autoload.php';

# verify token
if(Token::verify()) {
    # ...
}
<!-- in form, dont forget to import class -->
<form method="post">
    <?= Token::set() ?>
</form>

You can change the name of the key that store data in session and post by passing it in param of the function

Token::set('csrf');
Token::verify('csrf');

Licence

This code is licenced under MIT licence