You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php$form = newForm();
// enable csrf passing key used for $_SESSION and $_POST$form->enableCsrf('csrf_token');
// add csrf token into hidden field$form->csrfToken();
$form->text('username');
$form->password('password');
$form->password('confirm_password');
$form->submit('submit_button', 'Click to Continue');
// when post is submit, check tokenif($form->checkCsrf()) echo'csrf passed';
elseecho'csrf failed';
// optional we can add timestamp, so token expire after X minutes$timespan = 10; // 10 minutes$onetime = false; // disable use token onetime, usefull when ajax $throwException = true; // trow an exception if failedif($form->checkCsrf($timespan, $onetime, $throwException))
...
hi
I have added a csrf protection to the class, you can see here:
https://github.com/macagoraga/form/commit/d0cad864f75de097fef2b47378d3bc5adeaaec4f
Usage:
Inspired by https://github.com/BKcore/NoCSRF
The text was updated successfully, but these errors were encountered: