PHP code example of psecio / csrf

1. Go to this page and download the library: Download psecio/csrf 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/ */

    

psecio / csrf example snippets



ager = new \Psecio\Csrf\Manager();

if (isset($_POST['sub'])) {
    $result = $manager->verify($_POST['csrf-token']);
    if ($result === false) {
        echo 'Bad token! Shame on you...';
    }
}


$manager = new \Psecio\Csrf\Manager(true);



class DbStorage
{
    public function save($key, $code)
    {
        // Save to the database here...
    }
    public abstract function get($key)
    {
        // Read from the database here
    }
    public abstract function delete($key)
    {
        // Delete from the database here
    }
}
$dbStorage = new DbStorage();
$manager = new Manager(false, $dbStorage);