duncanmcclean/cookie-notice
Cookie Notice is a lightweight Statamic addon that adds a configurable cookie consent banner to your site. Customize the message and policy link, style it to match your theme, and remember visitors’ consent with a simple cookie. Easy to set up and suitable for most sites.
composer require duncanmcclean/cookie-noticephp artisan vendor:publish --tag=cookie-notice-configDuncanMcClean\CookieNotice\Http\Middleware\InjectCookieNotice in your web middleware group (in app/Http/Kernel.php for Laravel ≤10, or bootstrap/app.php for Laravel 11+). This automatically injects the notice before </body>.config/cookie-notice.php: enable the notice, set the text, buttons, cookie name, and expiry.@if(CookieNotice::hasAccepted('analytics'))
<script src="https://analytics.example.com/script.js"></script>
@endif
analytics, marketing) in the config, then use CookieNotice::hasAccepted('analytics') in Blade or CookieNotice::hasBeenAccepted() for general consent.php artisan vendor:publish --tag=cookie-notice-views) and edit the notice Blade file. Publish assets if you need to modify CSS/JS.php artisan vendor:publish --tag=cookie-notice-translations) and add locale files.CookieNotice facade in controllers or middleware to conditionally enable server-side tracking or features.$this->withCookie('cookie_notice', json_encode(['accepted' => ['analytics']])), or use the package’s testing helpers if available.web group. If using full-page caching, the notice may be cached—exclude pages or render the notice dynamically.cookie_name after users have consented resets their preferences. Keep it stable.php artisan config:clear after editing config/cookie-notice.php.How can I help you explore Laravel packages today?