PHP code example of statikbe / laravel-cookie-consent
1. Go to this page and download the library: Download statikbe/laravel-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/ */
statikbe / laravel-cookie-consent example snippets
return [
/*
* Theme for the cookie consent popup.
* Options: 'default', 'filament'
*/
'theme' => 'default',
/*
* Filament render hook used to register the cookie settings nav item.
* Set to null to disable the nav item entirely.
* See: Filament Integration > Nav item
*/
'filament-nav-item-render-hook' => \Filament\View\PanelsRenderHook::USER_MENU_PROFILE_AFTER,
/*
* Name of the cookie written to the browser.
* If you change this, update the GTM variable name to match.
*/
'cookie_key' => '__cookie_consent',
/*
* Values written to the cookie for each consent choice.
*
* analytics only => '2'
* marketing only => '3'
* both accepted => 'true'
* none accepted => 'false'
*
* GTM reads this value with regex triggers to decide which tags fire.
* If you change these values, update your GTM triggers to match.
*/
'cookie_value_analytics' => '2',
'cookie_value_marketing' => '3',
'cookie_value_both' => 'true',
'cookie_value_none' => 'false',
'cookie_expiration_days' => '365',
/*
* GTM custom event fired after the visitor saves their preferences.
*/
'gtm_event' => 'cookie_refresh',
/*
* Relative paths where the cookie banner is suppressed.
* Accepts wildcards via Str::is() — e.g. '/api/*', '/en/cookie-policy'.
*/
'ignored_paths' => [],
/*
* Set to true to suppress the banner on 4xx/5xx error pages.
*/
'skip_on_error_responses' => false,
/*
* Mark the consent cookie as Secure (HTTPS only).
* Reads from the COOKIE_CONSENT_SECURE env variable.
*/
'cookie_secure' => env('COOKIE_CONSENT_SECURE', false),
/*
* Cookie policy page URLs shown in the banner.
* Read from env — add only the locales your site supports.
*/
'policy_url_en' => env('COOKIE_POLICY_URL_EN', null),
'policy_url_fr' => env('COOKIE_POLICY_URL_FR', null),
'policy_url_nl' => env('COOKIE_POLICY_URL_NL', null),
];