{"id":26255264,"url":"https://github.com/scify/laravel-cookie-guard","last_synced_at":"2026-03-16T09:06:01.344Z","repository":{"id":63410244,"uuid":"567666846","full_name":"scify/laravel-cookie-guard","owner":"scify","description":"A Laravel package that provides a Cookies consent floating window and publishes the Cookies for the different consent categories","archived":false,"fork":false,"pushed_at":"2025-03-25T14:48:58.000Z","size":983,"stargazers_count":111,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T21:06:46.186Z","etag":null,"topics":["cookies","cookies-consent","gdpr","gdpr-checklist","gdpr-compliant","gdpr-consent","gdpr-cookie","hacktoberfest","laravel","laravel-framework","laravel-package","laravel-plugin","php","php-package","php-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-18T09:46:02.000Z","updated_at":"2025-03-28T08:04:55.000Z","dependencies_parsed_at":"2023-02-01T05:30:50.418Z","dependency_job_id":"d859faf5-0ecc-40ac-acb6-80f802dc43dc","html_url":"https://github.com/scify/laravel-cookie-guard","commit_stats":{"total_commits":85,"total_committers":4,"mean_commits":21.25,"dds":0.4,"last_synced_commit":"433a079faf179041a92437736c562a487b8b37ee"},"previous_names":["scify/laravel-cookie-guard","scify/laravel-cookies-consent"],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scify%2Flaravel-cookie-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scify%2Flaravel-cookie-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scify%2Flaravel-cookie-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scify%2Flaravel-cookie-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scify","download_url":"https://codeload.github.com/scify/laravel-cookie-guard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406084,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookies","cookies-consent","gdpr","gdpr-checklist","gdpr-compliant","gdpr-consent","gdpr-cookie","hacktoberfest","laravel","laravel-framework","laravel-package","laravel-plugin","php","php-package","php-plugin"],"created_at":"2025-03-13T19:18:05.407Z","updated_at":"2026-03-16T09:06:01.329Z","avatar_url":"https://github.com/scify.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- omit in toc --\u003e\n\n# Laravel Cookie Guard - Make your Laravel app compliant with the EU GDPR cookie law\n\nThe **last** Cookies Consent Plugin your **Laravel app** will ever need!\n\n![logo](readme-images/Laravel_Cookie_Guard.png)\n\n\u003chr\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/scify/laravel-cookie-guard.svg?style=flat-square)](https://packagist.org/packages/scify/laravel-cookie-guard)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/scify/laravel-cookie-guard/run-tests.yml?branch=main)](https://github.com/scify/laravel-cookie-guard/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![codecov](https://codecov.io/gh/scify/laravel-cookie-guard/graph/badge.svg)](https://codecov.io/gh/scify/laravel-cookie-guard)\n[![Total Downloads](https://img.shields.io/packagist/dt/scify/laravel-cookie-guard.svg?style=flat-square)](https://packagist.org/packages/scify/laravel-cookie-guard)\n[![GitHub Issues](https://img.shields.io/github/issues/scify/laravel-cookie-guard)](https://img.shields.io/github/issues/scify/laravel-cookie-guard)\n[![GitHub Stars](https://img.shields.io/github/stars/scify/laravel-cookie-guard)](https://img.shields.io/github/stars/scify/laravel-cookie-guard)\n[![GitHub forks](https://img.shields.io/github/forks/scify/laravel-cookie-guard)](https://img.shields.io/github/forks/scify/laravel-cookie-guard)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)\n[![Ask Me Anything !](https://img.shields.io/badge/Ask%20me-anything-1abc9c.svg)](https://GitHub.com/scify)\n[![GitHub contributors](https://img.shields.io/github/contributors/scify/laravel-cookie-guard)](https://github.com/scify/laravel-cookie-guard/graphs/contributors)\n[![GitHub pull-requests](https://img.shields.io/github/issues-pr/scify/laravel-cookie-guard)](https://github.com/scify/laravel-cookie-guard/pulls)\n[![GitHub closed pull-requests](https://img.shields.io/github/issues-pr-closed/scify/laravel-cookie-guard)](https://github.com/scify/laravel-cookie-guard/pulls?q=is%3Apr+is%3Aclosed)\n\n\u003c!-- omit in toc --\u003e\n\n## Table of Contents\n\n- [Laravel Cookie Guard - Make your Laravel app compliant with the EU GDPR cookie law](#laravel-cookie-guard---make-your-laravel-app-compliant-with-the-eu-gdpr-cookie-law)\n  - [Table of Contents](#table-of-contents)\n  - [Upgrading to v4](#upgrading-to-v4)\n  - [About the plugin](#about-the-plugin)\n  - [Features](#features)\n  - [Installation](#installation)\n    - [SEO](#seo)\n    - [Explanation of the configuration file](#explanation-of-the-configuration-file)\n  - [Usage](#usage)\n    - [Option 1: All-in-one dialog (default)](#option-1-all-in-one-dialog-default)\n    - [Option 2: Simple dialog, with a link to the default separate internal page](#option-2-simple-dialog-with-a-link-to-the-default-separate-internal-page)\n    - [Option 3: Simple dialog, with a link to a customized separate internal page with navbars, footers, etc.](#option-3-simple-dialog-with-a-link-to-a-customized-separate-internal-page-with-navbars-footers-etc)\n    - [Option 4: Simple dialog, with a link to an external (off-the-app) page](#option-4-simple-dialog-with-a-link-to-an-external-off-the-app-page)\n  - [How to override the CSS styles](#how-to-override-the-css-styles)\n  - [How to add a new cookie category](#how-to-add-a-new-cookie-category)\n  - [How to check if a cookie category is allowed](#how-to-check-if-a-cookie-category-is-allowed)\n    - [Backend code](#backend-code)\n    - [Frontend code](#frontend-code)\n  - [Customization](#customization)\n    - [Customizing the component texts](#customizing-the-component-texts)\n    - [Customizing the component contents](#customizing-the-component-contents)\n  - [Development](#development)\n    - [Testing](#testing)\n  - [FAQ](#faq)\n  - [Changelog](#changelog)\n  - [Contributing](#contributing)\n    - [PHP code style - Laravel Pint](#php-code-style---laravel-pint)\n    - [Releasing a new version](#releasing-a-new-version)\n  - [Credits](#credits)\n  - [License](#license)\n\n## Upgrading to v4\n\nAs of **March 2025**, The `v4` of the Laravel Cookies Consent plugin has been released! 🎉🥳😍\nIt offers a **new, revamped UI**, and a lot of new features and improvements.\n\n**Important:**\nSince the plugin now has a completely new name, you will need to uninstall the old package, and install the new one.\n\n```bash\nrm -rf public/vendor/scify \u0026\u0026 rm -rf vendor/scify\n\ncomposer remove scify/laravel-cookies-consent\n\ncomposer require scify/laravel-cookie-guard\n\nphp artisan vendor:publish --provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" --tag=\"cookies-consent-public\" --force\n```\n\nThen, make sure to check the configuration file `config/cookies_consent.php` and update it according\nto [the new one](config/cookies_consent.php).\n\nThen, make sure that the Laravel components you use are the new ones:\n\nIntead of using:\n\n```html\n\n\u003cx-laravel-cookies-consent\u003e\u003c/x-laravel-cookies-consent\u003e\n```\n\nUse:\n\n```html\n\n\u003cx-laravel-cookie-guard-scripts\u003e\u003c/x-laravel-cookie-guard-scripts\u003e\n\u003cx-laravel-cookie-guard\u003e\u003c/x-laravel-cookie-guard\u003e\n```\n\nIn order to upgrade to `v4`, please follow the instructions in the [CHANGELOG](CHANGELOG.md) file, and consult also\nthe [How To Upgrade to a New Major Version](UPGRADING.md) file.\n\nThen, make sure to publish the assets, the translations, and the configuration file, and update your Blade files\n\n## About the plugin\n\nAccording to the [GDPR law](https://gdpr-info.eu/), every platform is required to allow the users to decide which cookie\ncategories they will allow,\nand, if a cookie category is not allowed, the application should not use the functionality tied to that cookie.\n\nThis plugin provides a simple cookie consent window through which the user can specify the cookies they would like to\nallow.\n\nAfter the user submission, the page reloads and the relevant cookies are set on the browser, and can then be used in the\nfront-end.\n\n## Features\n\n- Customizable cookie categories\n- 3 Different integration options: All-in-one dialog, internal page, external separate page,\n- A clean and intuitive UI for the cookies consent modal.\n- A sticky cookies button and footer link that allows users to change their cookies preferences at any time. This button\n  is optional, and\n  it's existence can be tweaked in the configuration file.\n- A separate page for the cookies preferences, where users can read more about each cookie category and change their\n  preferences.\n- Multilingual support. The plugin comes with 6 built-in languages: English, Greek, Spanish, German, Italian, and\n  Swedish. You can add your own language by publishing the translations and editing/adding your own translations.\n\n## Installation\n\n1. You can install the package via composer:\n\n```bash\ncomposer require scify/laravel-cookie-guard\n```\n\n2. Then, **Make sure to manually publish** the cookie image file, by running:\n\n```bash\nphp artisan vendor:publish \\\n--provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" \\\n--tag=\"cookies-consent-public\"\n```\n\n**Notice:** if a new version of the plugin has been released, and you want to update the front-end files, please make\nsure to\nuse `--force` option, to overwrite the file.\n\nBy doing so, the image file will be copied to `public/vendor/scify/laravel-cookie-guard`.\n\n**IMPORTANT:**\n\nYou can then either decide to include the `public/vendor/scify/laravel-cookie-guard/*` files to git (especially if\nyou\nwant\nto edit it first), or add it to `.gitignore`, and make sure to also run this command on the staging/production server.\n\nNext, you need to publish the config file:\n\n```bash\nphp artisan vendor:publish \\\n--provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" \\\n--tag=\"cookies-consent-config\"\n```\n\nThe configuration file will be published to `config/cookies_consent.php`.\n\n3. Use the provided Laravel View Components\n\nIn order to use the plugin, you need to include the Laravel View Components in your Blade files, where you want the\ncookies to appear (typically just before the closing `\u003c/body\u003e` tag):\n\n```html\n\n\u003cx-laravel-cookie-guard\u003e\u003c/x-laravel-cookie-guard\u003e\n\u003cx-laravel-cookie-guard-scripts\u003e\u003c/x-laravel-cookie-guard-scripts\u003e\n```\n\n### SEO\n\nTip: Depending on the HTML structure of your app, you can specify the `heading` and `accordion-heading` attributes, so that the SEO rules are respected:\n\n```html\n\u003cx-laravel-cookie-guard heading=\"h2\" accordion-heading=\"h5\" /\u003e\n```\n\nThis will impact the heading level of the \"We value your privacy\" dialog title, and the \"Read More\" accordion titles.\n\n### Explanation of the configuration file\n\nIn the config file, you can change the cookie categories of your application, set the required and pre-selected\ncategories, as well as add new categories.\n\nThis is the contents of the published config file:\n\n```bash\nreturn [\n    /**\n     * This prefix will be applied when setting and getting all cookies.\n     * If not set, the cookies will not be prefixed.\n     * If set, a good strategy is to also add a trailing underscore \"_\", that will be added between the field value, and each cookie.\n     * For example, if `cookie_prefix` is set to `my_app_`, then the targeting cookie will have a value of `my_app_cookies_consent_targeting`.\n     * When using this plugin for multiple apps, it is a good strategy to set a prefix that is relevant to the app\n     * (for example \"my_app_\", in order for the cookies not to be mingled when running locally.\n     */\n    'cookie_prefix' =\u003e '',\n    'display_floating_button' =\u003e true, // Set to false to display the footer link instead\n    'hide_floating_button_on_mobile' =\u003e false, // Set to true to hide the floating button on mobile\n    'use_separate_page' =\u003e false, // Set to true to use a separate page for cookies explanation\n    'categories_collapsed_by_default' =\u003e true, // Set to false to initially collapse the optional categories\n    'use_show_modal' =\u003e true, // Set to false to disable the use of showModal() on the dialog HTML element\n    /*\n    |--------------------------------------------------------------------------\n    | Editor\n    |--------------------------------------------------------------------------\n    |\n    | Choose your preferred cookies to be shown. You can add more cookies as desired.\n    | If, for example you add another cookie with the name \"marketing\", then you should also\n    | publish the translation files and add a \"cookie_marketing\" key in the translation file,\n    | since the plugin will try to display the cookie name by this convention.\n    |\n    | Built-in: \"strictly_necessary\"\n    |\n    */\n    'cookies' =\u003e [\n        'strictly_necessary' =\u003e [\n            [\n                // you need to change this in order to reflect the cookie_prefix from above\n                'name' =\u003e 'my_app_cookies_consent',\n                'description' =\u003e 'cookies_consent::messages.cookie_cookies_consent_description',\n                'duration' =\u003e 'cookies_consent::messages.years',\n                'duration_count' =\u003e 2,\n                'policy_external_link' =\u003e null,\n            ],\n            [\n                'name' =\u003e 'XSRF-TOKEN',\n                'description' =\u003e 'cookies_consent::messages.cookie_xsrf_token_description',\n                'duration' =\u003e 'cookies_consent::messages.hours',\n                'duration_count' =\u003e 2,\n                'policy_external_link' =\u003e null,\n            ],\n            [\n                'name' =\u003e 'laravel_session',\n                'description' =\u003e 'cookies_consent::messages.cookie_laravel_session_description',\n                'duration' =\u003e 'cookies_consent::messages.hours',\n                'duration_count' =\u003e 2,\n                'policy_external_link' =\u003e null,\n            ],\n        ],\n    ],\n    'enabled' =\u003e [\n        'strictly_necessary',\n    ],\n    'required' =\u003e ['strictly_necessary'],\n    /*\n     * Set the cookie duration in days.  Default is 365 days.\n     */\n    'cookie_lifetime' =\u003e 365,\n];\n```\n\nThe `cookie_prefix` is optional and, if set, will be applied to every cookie.\n\nIf set, a good strategy is to also add a trailing underscore \"_\", that will be added between the field value, and each\ncookie.\n\nFor example, if `cookie_prefix` is set to `my_app_`, then the targeting cookie will have a value\nof `my_app_cookies_consent_targeting`.\n\nThe `display_floating_button` field is optional and, if set to `true`, will display a floating button in the bottom\nright corner of the page.\nIf set to `false`, then you will need to add a relevant link in your footer, in order to show the cookies preferences\ndialog:\n\n```html\n\u003ca href=\"javascript:void(0);\" onclick=\"toggleCookieBanner()\" onkeyup=\"if (event.key === 'Enter') toggleCookieBanner()\"\n   role=\"button\" aria-label=\"{{ __('cookies_consent::messages.cookies_settings') }}\"\u003e\n  {{ __('cookies_consent::messages.cookies_settings') }}\n\u003c/a\u003e\n```\n\nIf you prefer opening the dialog by hash, you can use:\n\n```html\n\u003ca href=\"#consent-settings\"\n   role=\"button\" aria-label=\"{{ __('cookies_consent::messages.cookies_settings') }}\"\u003e\n  {{ __('cookies_consent::messages.cookies_settings') }}\n\u003c/a\u003e\n```\n\nThe `hide_floating_button_on_mobile` field is optional and, if set to `true`, will hide the floating button on mobile\n\nThe `use_separate_page` field is optional and, if set to `true`, will display the cookies preferences in a separate\npage.\n\nThe `categories_collapsed_by_default` field is optional and, if set to `false`, will initially collapse the optional\ncategories.\nIf set to `true`, all categories will be collapsed by default.\n\nThe `use_floating_modal` field is optional and, if set to `true`, will disable the use of `showModal()` on the dialog HTML,\nand the fully-accessible modal. It will show a floating window on the left, instead.\n\nYou can add as many cookie categories as you like, simply by adding values to the `cookies` array.\n\nIf you want to remove a cookie category, simply remove it from the array.\n\nYou can use the `enabled` array to set the cookie categories that will be pre-selected,\nand the `required` array to set the cookies that the user won't be able to deselect.\n\nIf you want to change how long the cookies will be stored, edit the `cookie_lifetime` variable.\n\n## Usage\n\n### Option 1: All-in-one dialog (default)\n\n**Suitable for**: Apps that would like to show a single dialog with all the cookie categories.\n\nWhen the plugin is installed, a `laravel-cookie-guard`\ncustom [Laravel View Component](https://laravel.com/docs/9.x/blade#components) is automatically registered.\n\nThis will render the following cookies consent that, will look very much like this one.\n\n![dialog 1](readme-images/dialog_1.png)\n\nWhen the user cliks on \"Customise\", they will see the following dialog:\n\n![dialog 2](readme-images/dialog_2.png)\n\nThey then can open each cookies category and see the cookies:\n\n![dialog 3](readme-images/dialog_3.png)\n\nYou can then use this component in order to display the cookies consent window, wherever you'd like.\n\nTypically, a good strategy is to put the component just before the closing `\u003cbody\u003e` tag:\n\n```html\n\n\u003cbody\u003e\n...\n...\n...\n\u003cx-laravel-cookie-guard\u003e\u003c/x-laravel-cookie-guard\u003e\n\u003cx-laravel-cookie-guard-scripts\u003e\u003c/x-laravel-cookie-guard-scripts\u003e\n\u003c/body\u003e\n```\n\n(Or you can put the scripts in the `\u003chead\u003e` tag, if you prefer).\n\n### Option 2: Simple dialog, with a link to the default separate internal page\n\n**Suitable for**: Apps that would like to show a simple \"Accept all/Reject Optional\" dialog with a link to a separate\npage for customizing the cookies preferences.\n\nEdit the `config/cookies_consent.php` file, and set the `use_separate_page` field to `true`.\n\n```php\n    'use_separate_page' =\u003e true,\n```\n\nWhen the plugin is installed, a `/cookie-policy/{locale}` route is automatically registered.\nSo, you can edit the `config/cookies_consent.php` file, and set the `use_separate_page` field to `true`.\n\nNow, the user will see a simple dialog, with a link to the `/cookie-policy/{locale}` page, where they can customize\ntheir cookies preferences.\nThis page is managed by the plugin, and it will show the cookies categories, descriptions, and the ability to accept or\nreject them.\n\n### Option 3: Simple dialog, with a link to a customized separate internal page with navbars, footers, etc.\n\n**Suitable for**: Apps that would like to show a simple \"Accept all/Reject Optional\" dialog with a link to a customized\npage, with the app's own content (navigation, footer, etc).\n\nIf you would like to show a simple \"Accept all/Reject Optional\" dialog with a link to a separate page for customizing\nthe cookies preferences, you can set the following in the `config/cookies_consent.php` file:\n\n```php\n'use_separate_page' =\u003e true,\n'cookie_policy_page_custom_url' =\u003e '/my-custom-cookies-policy',\n```\n\n```php\nRoute::get('/my-custom-cookies-policy', function () {\n    return view('my-custom-cookies-policy');\n});\n```\n\nOr you can declare your route to override the default one:\n\n```php\n'use_separate_page' =\u003e true,\n'cookie_policy_page_custom_url' =\u003e null,\n```\n\nAnd then create a new route in your `routes/web.php` file:\n\n```php\nRoute::get('/cookie-policy/{locale}', function () {\n    return view('my-custom-cookies-policy');\n});\n```\n\nThen, you can create a new route in your `routes/web.php` file:\n\nNow, in the `resources/views/my-custom-cookies-policy.blade.php` file, you will need to render the\n`x-laravel-cookie-guard-page` component, in order to show the cookies preferences dialog.\n\nHere is a usage example:\n\n```bladehtml\n@extends('layouts.app')\n@section('head)\n\u003cx-laravel-cookie-guard-scripts\u003e\u003c/x-laravel-cookie-guard-scripts\u003e\n@endsection\n@section('content')\n\u003cx-laravel-cookie-guard-page\u003e\u003c/x-laravel-cookie-guard-page\u003e\n@endsection\n```\n\nThen, the user will see an appropriate dialog, with a link to the `/my-custom-cookies-policy` page:\n\n![dialog 4](readme-images/dialog_4.png)\n\n### Option 4: Simple dialog, with a link to an external (off-the-app) page\n\n**Suitable for**: Apps that would like to show a simple \"Accept all/Reject Optional\" dialog, with a link to an external\nURL.\n\nIf you would like to show a simple \"Accept all/Reject Optional\" dialog with a link to an external URL, you can set the\nfollowing in the `config/cookies_consent.php` file:\n\n```php\n    'use_separate_page' =\u003e true,\n    'cookie_policy_page_custom_url' =\u003e 'https://www.example.com/cookies-policy',\n```\n\nThen, the user will see an appropriate dialog, with a link to the external page.\n\n## How to override the CSS styles\n\nIf you want to override the CSS styles of the cookies consent dialog, you can do this:\n\n```html\n\n\u003cx-laravel-cookie-guard\u003e\u003c/x-laravel-cookie-guard\u003e\n\u003cx-laravel-cookie-guard-scripts\u003e\u003c/x-laravel-cookie-guard-scripts\u003e\n```\n\nThen, you can add a `\u003cstyle\u003e` tag in your Blade file, in order to override the CSS styles:\n\n```html\n\n\u003cstyle\u003e\n  #scify-cookies-consent, #scify-cookie-policy-page, #scify-cookie-consent-floating-button {\n    --scify-cookies-primary-color: #ff5722; /* Override primary color */\n\n    ...\n\n    /* Add more override rules here */\n  }\n\u003c/style\u003e\n```\n\nThe full list of CSS variables that can be overridden can be found in the\n`public/vendor/scify/laravel-cookie-guard/_variables.css` file.\n\n## How to add a new cookie category\n\nIn order to add a new cookie category, you need to add a new entry in the `cookies` array in the configuration file:\n\n```php\n        'strictly_necessary' =\u003e [\n            ...\n            ...\n        ],\n        'targeting' =\u003e [\n            [\n                'name' =\u003e '_ga',\n                'description' =\u003e 'This cookie is installed by Google Analytics. The cookie is used to calculate visitor, session, campaign data and keep track of site usage for the site\\'s analytics report. The cookies store information anonymously and assign a randomly generated number to identify unique visitors.',\n                'duration' =\u003e 'cookies_consent::messages.years',\n                'duration_count' =\u003e 2,\n                'policy_external_link' =\u003e 'https://policies.google.com/privacy?hl=en-US',\n            ],\n            [\n                'name' =\u003e '_gid',\n                'description' =\u003e 'This cookie is installed by Google Analytics. The cookie is used to store information of how visitors use a website and helps in creating an analytics report of how the website is doing. The data collected including the number visitors, the source where they have come from, and the pages visited in an anonymous form.',\n                'duration' =\u003e 'cookies_consent::messages.days',\n                'duration_count' =\u003e 1,\n                'policy_external_link' =\u003e 'https://policies.google.com/privacy?hl=en-US',\n            ],\n            [\n                'name' =\u003e '_gat',\n                'description' =\u003e 'This cookies is installed by Google Universal Analytics to throttle the request rate to limit the colllection of data on high traffic sites.',\n                'duration' =\u003e 'cookies_consent::messages.minutes',\n                'duration_count' =\u003e 1,\n                'policy_external_link' =\u003e 'https://policies.google.com/privacy?hl=en-US',\n            ],\n        ],\n```\n\nOr, you can set the `description` to be null (or an empty string), or set a translation key directly, like so:\n\n1. Create a cookies-specific translation file:\n\n```bash\n touch lang/en/cookies.php\n```\n\nContents:\n\n```php\n\u003c?php\n\nreturn [\n    'google_analytics' =\u003e [\n        '_ga_description' =\u003e 'This cookie is installed by Google Analytics. The cookie is used to calculate visitor, session, campaign data and keep track of site usage for the site\\'s analytics report. The cookies store information anonymously and assign a randomly generated number to identify unique visitors.',\n        '_gid_description' =\u003e 'This cookie is installed by Google Analytics. The cookie is used to store information of how visitors use a website and helps in creating an analytics report of how the website is doing. The data collected including the number visitors, the source where they have come from, and the pages visited in an anonymous form.',\n        '_gat_description' =\u003e 'This cookies is installed by Google Universal Analytics to throttle the request rate to limit the colllection of data on high traffic sites.',\n    ]\n];\n```\n\nThen, in your `config/cookies_consent.php` file, you can set the `description` fields to be the translation keys.\nNotice that the `description` fields have `cookies.google_analytics.*` values: (from the `cookies.php` file we just\ncreated).\n\n```php\n        'strictly_necessary' =\u003e [\n            ...\n            ...\n        ],\n        'targeting' =\u003e [\n            [\n                'name' =\u003e '_ga',\n                'description' =\u003e 'cookies.google_analytics._ga_description',\n                'duration' =\u003e 'cookies_consent::messages.years',\n                'duration_count' =\u003e 2,\n                'policy_external_link' =\u003e 'https://policies.google.com/privacy?hl=en-US',\n            ],\n            [\n                'name' =\u003e '_gid',\n                'description' =\u003e 'cookies.google_analytics._gid_description',\n                'duration' =\u003e 'cookies_consent::messages.days',\n                'duration_count' =\u003e 1,\n                'policy_external_link' =\u003e 'https://policies.google.com/privacy?hl=en-US',\n            ],\n            [\n                'name' =\u003e '_gat',\n                'description' =\u003e 'cookies.google_analytics._gat_description',\n                'duration' =\u003e 'cookies_consent::messages.minutes',\n                'duration_count' =\u003e 1,\n                'policy_external_link' =\u003e 'https://policies.google.com/privacy?hl=en-US',\n            ],\n        ],\n\n```\n\n## How to check if a cookie category is allowed\n\n### Backend code\n\nYou can use the `$_COOKIE` global object, in order to check for the appropriate cookie.\n\nNow you can use this object in your Blade files like this:\n\n```bash\n$_COOKIE[config('cookies_consent.cookie_prefix') . {{ COOKIE_NAME }}]\n```\n\nFor example, An application that wants to load the Google Analytics script only if the user has given their consent to\nthe `targeting` cookie category,\nmight do the following:\n\n```php\n\u003c!-- Check the 'targeting' cookie: --\u003e\n@if(isset($_COOKIE[config('cookies_consent.cookie_prefix') . 'cookies_consent']))\n    @php\n        $cookiesConsent = json_decode($_COOKIE[config('cookies_consent.cookie_prefix') . 'cookies_consent'], true);\n    @endphp\n    @if(isset($cookiesConsent['targeting']) \u0026\u0026 $cookiesConsent['targeting'] \u0026\u0026 config('app.google_analytics_id'))\n        \u003c!-- Google Analytics --\u003e\n        \u003cscript defer async\u003e\n            (function (i, s, o, g, r, a, m) {\n                i['GoogleAnalyticsObject'] = r;\n                i[r] = i[r] || function () {\n                    (i[r].q = i[r].q || []).push(arguments)\n                }, i[r].l = 1 * new Date();\n                a = s.createElement(o),\n                    m = s.getElementsByTagName(o)[0];\n                a.async = 1;\n                a.src = g;\n                m.parentNode.insertBefore(a, m)\n            })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');\n\n            window.ga('create', '{{ config('app.google_analytics_id') }}', 'auto');\n            window.ga('set', 'anonymizeIp', true);\n            window.ga('send', 'pageview');\n        \u003c/script\u003e\n    @endif\n@endif\n```\n\nIn this example, we checked whether\nthe `$_COOKIE[config('cookies_consent.cookie_prefix') . 'cookies_consent_targeting']` key exists or not.\n\n### Frontend code\n\nYou can use the `window.localStorage` object, in order to check for the appropriate cookie. (declared in the\nconfiguration file)\n\n## Customization\n\n### Customizing the component texts\n\nIf you want to modify the texts shown in the cookies dialog, you can publish the language resource files with this\ncommand:\n\n```bash\nphp artisan vendor:publish \\\n--provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" \\\n--tag=\"cookies-consent-translations\"\n```\n\nThis will publish the translation files to `lang/vendor/scify/laravel-cookie-guard/` directory.\n\nThe plugin comes with many built-in languages. You can change the translations for a given language, or add additional\nlanguages yourself.\n\n### Customizing the component contents\n\nIf you need full control over the contents of the cookies dialog, you can publish the views of the package:\n\n```bash\nphp artisan vendor:publish \\\n--provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" \\\n--tag=\"cookies-consent-components\"\n```\n\nThis will copy the view files over to `resources/views/components/vendor/scify/laravel-cookie-guard` directory.\n\n## Development\n\nIn order to locally run the package, you should use a local Laravel application, in which you are going to install it.\n\nMake sure that the `composer.json` file of the Laravel app has the following entry:\n\n```text\n\n\"require\": {\n    \"scify/laravel-cookie-guard\": \"@dev\",\n}\n...\n...\n\"repositories\": [\n        {\n            \"type\": \"path\",\n            \"url\": \"../path/to/laravel-cookie-guard/\",\n            \"options\": {\n                \"symlink\": true\n            }\n        }\n    ],\n\"minimum-stability\": \"dev\",\n```\n\nThis will tell composer that the code for the package is of the `\"@dev\"` version and that it exists in the specified\npath.\n\nThen run:\n\n```bash\ncomposer update scify/laravel-cookie-guard --prefer-source\n```\n\nTo fetch the local package.\n\nOr, to prune everything and re-install:\n\n```bash\nrm -rf public/vendor/scify \u0026\u0026 \\\nrm -rf vendor/scify \u0026\u0026 \\\ncomposer require scify/laravel-cookie-guard \u0026\u0026 \\\nphp artisan vendor:publish --provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" --tag=\"cookies-consent-public\" --force\n```\n\n### Testing\n\nThis project uses [Pest](https://pestphp.com/) for testing. To execute the test suite, run:\n\n```bash\ncomposer test\n```\n\n## FAQ\n\n**Question:** Is this plugin free to use?\n\n**Answer:** Yes. This plugin is totally free and developed as\nan [Open-Source project](https://github.com/scify/laravel-cookie-guard).\n\n---\n\n**Question:** How long do the cookies last?\n\n**Answer:** The duration is set in days, in `config/cookies_consent.php` file. In order to publish this file, run\n\n```bash\nphp artisan vendor:publish \\\n--provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" \\\n--tag=\"cookies-consent-config\"\n```\n\nThe configuration file will be published to `config/cookies_consent.php`.\n\nThen, edit the `cookie_lifetime` field (in days).\n\n---\n\n**Question:** Will the cookie consent window show every time?\n\n**Answer:** No. As soon as the user clicks one of the \"Accept all\", \"Accept selection\", or \"Decline all\", the selection\nwill be stored in another cookie, and the window won't pop up again, until this cookie expires, or is deleted.\n\n---\n\n**Question:** In which languages is the plugin available?\n\n**Answer:** The plugin has 6 built-in languages: English, Greek, Spanish, German, Italian, and Swedish. If you would\nlike to add a language, publish the translations by running:\n\n```bash\nphp artisan vendor:publish \\\n--provider=\"SciFY\\LaravelCookiesConsent\\LaravelCookiesConsentServiceProvider\" \\\n--tag=\"cookies-consent-translations\"\n```\n\nAnd add/change your own translations. If you add a new language, consider also opening\na [pull request](https://github.com/scify/laravel-cookie-guard/pulls), in order for this language to be included in\nthe plugin.\n\n---\n\n**Question:** Does this plugin work with all Laravel versions?\n\n**Answer:** We have tested the plugin with Laravel 7, 8, and 9. The plugin's simplicity allows it to work with any\nLaravel version, but if you try it with a version other that the tested ones and it does not work, please open an issue\non [GitHub](https://github.com/scify/laravel-cookie-guard/issues).\n\n---\n\n**Question:** If I install later a new cookie category, how can I force the plugin to \"reset\" and show again?\n\n**Answer:** The easiest way is to publish the configuration file, and change the `cookie_prefix` field. This will force\nthe plugin to show again.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for general details.\n\n### PHP code style - Laravel Pint\n\nThis application uses [Laravel Pint](https://laravel.com/docs/9.x/pint) in order to perform code-style.\n\nIn order to run the styler, run :\n\n```bash\n./vendor/bin/pint --test -v # the --test will not do any changes, it will just output the changes needed\n\n./vendor/bin/pint -v # this command will actually perform the code style changes\n```\n\n### Releasing a new version\n\nAfter you have committed your changes, create a new git tag:\n\n```bash\ngit tag -a vx.y.z -m \"This is a nice tag name\"\n```\n\n(for the `x.y.z` version number, follow the [Semantic Versioning](https://semver.org/) guidelines).\n\nThen, push the tag:\n\n```bash\ngit push origin vx.y.z\n```\n\nThen, in the [GitHub Releases page](https://github.com/scify/laravel-cookie-guard/releases), create a new Release *\n*and correlate it with the tag that you just created.**\n\nThat's it! Packagist will be updated automatically.\n\nAlso, don't forget to update the `CHANGELOG.md` file with the new version name, release date, and release notes.\n\n## Credits\n\n- [SciFY Dev Team](https://github.com/scify)\n\n## License\n\nThe Apache Licence. Please see the [Licence File](LICENCE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscify%2Flaravel-cookie-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscify%2Flaravel-cookie-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscify%2Flaravel-cookie-guard/lists"}