csrf($check = null)

Generates and checks CSRF tokens

  • $check (string)
    Token to check, will return boolean if set
  • return (string | boolean)

Example

Token generation

<input type="hidden" name="csrf" value="<?= csrf() ?>">

Checking the token

$token = get('csrf');
if(csrf($token) === true) {
  // Success
} else {
  // Token doesn't match
}