PHP code example of phpolar / csrf-protection

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

    

phpolar / csrf-protection example snippets


$csrfChecking = $this->container->get(CsrfRequestCheckMiddleware::class);
$csrfFiltering = $this->container->get(CsrfResponseFilterMiddleware::class);

$app->use($csrfChecking);
$app->use($csrfFiltering);

// ...

$response = $csrfCheckMiddleware->process($request, $nextHandler);

// ...

$preparedResponse = $middleWare->process($request, $routingHandler);