https://github.com/code16/cookie-consent-js
https://github.com/code16/cookie-consent-js
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/code16/cookie-consent-js
- Owner: code16
- Created: 2022-01-17T12:27:18.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-21T10:26:20.000Z (almost 4 years ago)
- Last Synced: 2024-04-14T06:08:33.622Z (almost 2 years ago)
- Language: Blade
- Size: 213 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cookie consent
## Setup
```bash
composer require code16/cookie-consent-js
```
**Required**: publish assets (add this in composer.json `post-autoload-dump` scripts)
```php
php artisan vendor:publish --provider='Code16\CookieConsent\CookieConsentServiceProvider' --tag=assets --force
```
You may publish the config file:
```php
php artisan vendor:publish --provider="Code16\CookieConsent\CookieConsentServiceProvider" --tag=config
```
And the lang file:
```php
php artisan vendor:publish --provider="Code16\CookieConsent\CookieConsentServiceProvider" --tag=lang
```
## Usage
In your blade layout
```blade
{{-- ... --}}
{{-- some injected cookies --}}
```
Also you must declare the cookie category in `config/cookie-consent.php` as follow
```php
[
'categories' => [
'system' => [
'required' => true,
'services' => [
[
'cookies' => []
]
]
],
'analytics' => [
'services' => [
'google-analytics' => [
'cookies' => [
['name' => '_ga', 'lifetime' => '2 years']
]
]
]
],
]
];
```
Categories marked as `required` are cannot be opt-out by the user.
To provide explanation texts in the manage dialog, add content to the lang file:
```php
[
'manage_modal' => [
'title' => 'Manage cookies',
'description' => 'About cookies...',
'categories' => [
'system' => [
'title' => 'System cookies',
'description' => "Description text about system cookies",
],
'analytics' => [
'title' => 'Analytics cookies',
'description' => "Description text about analytics cookies",
],
],
]
];
```
### Show the manage modal from a link (e.g. cookies page)
In the page:
```blade
Open manage cookies modal
```