PHP code example of internetpixels / csrf-protection
1. Go to this page and download the library: Download internetpixels/csrf-protection library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
internetpixels / csrf-protection example snippets
TokenManager::setSalt('P*17OJznMttaR#Zzwi4YhAY!H7hPGUCd', 'ERGirehgr4893ur43tjrg98rut98ueowifj');
TokenManager::setUserId(7);
TokenManager::setSessionToken('session_token');
<form action="/your/page" method="post">
<?= TokenManager::createHtmlField('my_form')
if( filter_has_var(INPUT_POST, '_token') ) {
if( TokenManager::validate('my_form', filter_input(INPUT_POST, '_token')) ) {
// valid token
}
else {
// invalid token
}
}