PHP code example of selective / samesite-cookie

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

    

selective / samesite-cookie example snippets




use Selective\SameSiteCookie\SameSiteCookieMiddleware;
use Slim\Factory\AppFactory;

$app = AppFactory::create();

// ...

// Register the samesite cookie middleware
$app->add(new SameSiteCookieMiddleware());

// ...

$app->run();



use Selective\SameSiteCookie\SameSiteCookieConfiguration;
use Selective\SameSiteCookie\SameSiteCookieMiddleware;
use Selective\SameSiteCookie\SameSiteSessionMiddleware;
use Slim\Factory\AppFactory;

$app = AppFactory::create();

// ...

// Optional: Add custom configuration
$configuration = new SameSiteCookieConfiguration();

// Register the samesite cookie middleware
$app->add(new SameSiteCookieMiddleware($configuration));

// Optional: Start the PHP session
// Use this middleware only if you have no other session starter middleware
$app->add(new SameSiteSessionMiddleware());

// ...

$app->run();