- How do I install and set up Laravel Cookie Consent in a Laravel 13 project?
- Run `composer require jeffersongoncalves/laravel-cookie-consent`, then execute `php artisan migrate` to create the settings table. Add `@include('cookie-consent::cookie-consent-head')` and `@include('cookie-consent::cookie-consent-body')` to your layout file. No additional configuration is needed for basic usage.
- Does this package support GDPR and CCPA compliance out of the box?
- Yes, the package is explicitly designed for GDPR/CCPA compliance with structured consent management. It includes settings for necessary/analytics cookies and provides a foundation for CCPA’s 'Do Not Sell' requirements, though you may need to add a manual link for full CCPA compliance.
- Can I customize the cookie consent banner’s appearance beyond the default theme?
- You can publish the views with `php artisan vendor:publish --tag=cookie-consent-views` and modify the Blade templates in `resources/views/vendor/cookie-consent`. For deeper customization, override the underlying Osano library’s CSS or use the published assets tag to inject custom styles.
- What Laravel versions and PHP requirements does this package support?
- The package supports Laravel 9 through 13.x and requires PHP 8.1+. It is compatible with modern Laravel stacks but does not support Lumen. Always check the latest release notes for updates on supported versions.
- How do I block scripts until a user gives cookie consent?
- Create a middleware like `CheckCookieConsent` that checks for the `cookie_consent` cookie. Use it in your `Kernel.php` to block access to routes requiring consent. Example: `if (!$request->cookie('cookie_consent') && !$request->ipIsTrusted()) { abort(403); }`
- Is there a way to add multi-language support for the cookie consent banner?
- The package no longer includes built-in i18n support in v3.x, but you can manually override the published views in `resources/views/vendor/cookie-consent` and implement language-specific translations. Use Laravel’s localization features to dynamically load the correct text based on the user’s locale.
- What happens if the CDN hosting the cookie consent assets goes down?
- The package relies on CDN-hosted assets by default, but you can publish them locally with `php artisan vendor:publish --tag=cookie-consent-assets` to ensure availability. This is a good practice for production environments where uptime is critical.
- Can I integrate this package with Google Analytics or other analytics tools?
- The package does not include built-in analytics integration, but you can manually implement it using middleware or JavaScript. For example, block analytics scripts until consent is given, then load them dynamically based on the user’s consent status.
- Are there any alternatives to this package for Laravel cookie consent?
- Alternatives include `orangehill/isee` (for GDPR compliance) and `spatie/cookie-consent` (simpler but less feature-rich). This package stands out for its integration with `spatie/laravel-settings` for runtime configuration and its use of the Osano library for advanced cookie management.
- How do I update the package settings dynamically in real-time?
- Use the `CookieConsentSettings` class or the `cookie_consent_settings()` helper to access and modify settings at runtime. For example, `$settings = cookie_consent_settings(); $settings->position = 'bottom-right'; $settings->save();` This is useful for A/B testing or adjusting compliance text without redeploying.