PHP code example of atlasconsulting / cakephp-cookie-consent

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

    

atlasconsulting / cakephp-cookie-consent example snippets


public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
    return $middlewareQueue
        // Catch any exceptions in the lower layers,
        // and make an error page/response
        ->add(new ErrorHandlerMiddleware(Configure::read('Error')))

        ->add(new CookieConsentMiddleware([
            'remove' => [
                'preferences' => ['lang'], // remove `lang` cookie if `preferences` category isn't accepted
                'analytics' => ['my_analytics'], // remove `my_analytics` cookie if `analytics` category isn't accepted
            ],
        ]));

        // other middlewares here
}

[
    'cookieName' => 'cc_cookie',
    'searchIn' => 'level',
    'remove' => [
        'preferences' => [],
        'analytics' => [],
        'targeting' => [],
    ],
]