{"id":13396047,"url":"https://github.com/spatie/laravel-cookie-consent","last_synced_at":"2025-05-12T20:51:16.802Z","repository":{"id":9419671,"uuid":"62055265","full_name":"spatie/laravel-cookie-consent","owner":"spatie","description":"Make your Laravel app comply with the crazy EU cookie law","archived":false,"fork":false,"pushed_at":"2025-04-04T23:59:47.000Z","size":204,"stargazers_count":1446,"open_issues_count":0,"forks_count":142,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-04-08T22:14:50.373Z","etag":null,"topics":["cookie","eu","javascript","laravel","php"],"latest_commit_sha":null,"homepage":"https://freek.dev/503-make-your-laravel-app-comply-with-the-crazy-eu-cookie-law","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://spatie.be/open-source/support-us"}},"created_at":"2016-06-27T12:42:31.000Z","updated_at":"2025-04-08T19:19:39.000Z","dependencies_parsed_at":"2024-01-15T09:03:32.188Z","dependency_job_id":"77568f38-e2a9-44a8-92f6-cf5efdaac1f3","html_url":"https://github.com/spatie/laravel-cookie-consent","commit_stats":{"total_commits":226,"total_committers":68,"mean_commits":3.323529411764706,"dds":"0.42035398230088494","last_synced_commit":"ce9330841673baafa0289f3d2c8deeea63858c2f"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-cookie-consent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-cookie-consent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-cookie-consent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-cookie-consent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-cookie-consent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250489800,"owners_count":21439027,"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":["cookie","eu","javascript","laravel","php"],"created_at":"2024-07-30T18:00:38.326Z","updated_at":"2025-04-23T18:29:37.922Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://spatie.be/open-source/support-us"],"categories":["Popular Packages","PHP"],"sub_categories":[],"readme":"# Simple, customizable cookie consent message for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-cookie-consent.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-cookie-consent)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![run-tests](https://github.com/spatie/laravel-cookie-consent/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-cookie-consent/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-cookie-consent.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-cookie-consent)\n\nThis package adds a simple, customizable cookie consent message to your site. When the site loads, the banner appears and lets users consent to cookies. Once consent is given, the banner hides and stays hidden.\n\n**What this package does not:**\n- Include an option to 'Decline' all cookies, which might be required.\n- Block trackers and cookies before consent. You need to handle this yourself.\n- Include options for different consent categories like \"Necessary\" or \"Marketing\".\n\nFor more advanced cookie consent options in Laravel, consider these alternatives.\n\n- [whitecube/laravel-cookie-consent](https://github.com/whitecube/laravel-cookie-consent)\n- [statikbe/laravel-cookie-consent](https://github.com/statikbe/laravel-cookie-consent)\n- [devrabiul/laravel-cookie-consent](https://github.com/devrabiul/laravel-cookie-consent)\n\nIf you need an implementation of cookie consent for [Filament](https://github.com/filamentphp/filament) you can evaluate this plugin:\n\n- [marcogermani87/filament-cookie-consent](https://github.com/marcogermani87/filament-cookie-consent)\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-cookie-consent.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-cookie-consent)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require spatie/laravel-cookie-consent\n```\n\nThe package will automatically register itself.\n\nOptionally you can publish the config-file:\n\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\CookieConsent\\CookieConsentServiceProvider\" --tag=\"cookie-consent-config\"\n```\n\nThis is the contents of the published config-file:\n\n```php\nreturn [\n\n    /*\n     * Use this setting to enable the cookie consent dialog.\n     */\n    'enabled' =\u003e env('COOKIE_CONSENT_ENABLED', true),\n\n    /*\n     * The name of the cookie in which we store if the user\n     * has agreed to accept the conditions.\n     */\n    'cookie_name' =\u003e 'laravel_cookie_consent',\n\n    /*\n     * Set the cookie duration in days.  Default is 365 * 20.\n     */\n    'cookie_lifetime' =\u003e 365 * 20,\n];\n```\n\nThe cookie domain is set by the 'domain' key in config/session.php, make sure you add a value in your .env for SESSION_DOMAIN. If you are using a domain with a port in the url such as 'localhost:3000', this package will not work until you do so.\n\n## Usage\n\nTo display the dialog all you have to do is include this view in your template:\n\n```blade\n//in your blade template\n@include('cookie-consent::index')\n```\n\nThis will render the following dialog that, when styled, will look very much like this one.\n\n![dialog](https://spatie.github.io/laravel-cookie-consent/images/dialog.png)\n\nThe default styling provided by this package uses TailwindCSS v2 to provide a floating banner at the bottom of the page.\n\nWhen the user clicks \"Allow cookies\" a `laravel_cookie_consent` cookie will be set and the dialog will be removed from the DOM. On the next request, Laravel will notice that the `laravel_cookie_consent` has been set and will not display the dialog again\n\n## Customising the dialog texts\n\nIf you want to modify the text shown in the dialog you can publish the lang-files with this command:\n\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\CookieConsent\\CookieConsentServiceProvider\" --tag=\"cookie-consent-translations\"\n```\n\nThis will publish this file to `resources/lang/vendor/cookie-consent/en/texts.php`.\n\n ```php\n \n return [\n     'message' =\u003e 'Please be informed that this site uses cookies.',\n     'agree' =\u003e 'Allow cookies',\n ];\n ```\n \n If you want to translate the values to, for example, French, just copy that file over to `resources/lang/vendor/cookie-consent/fr/texts.php` and fill in the French translations.\n \n### Customising the dialog contents\n\nIf you need full control over the contents of the dialog. You can publish the views of the package:\n\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\CookieConsent\\CookieConsentServiceProvider\" --tag=\"cookie-consent-views\"\n```\n\nThis will copy the `index` and `dialogContents` view files over to `resources/views/vendor/cookie-consent`. You probably only want to modify the `dialogContents` view. If you need to modify the JavaScript code of this package you can do so in the `index` view file.\n\n## Using the middleware\n\nInstead of including `cookie-consent::index` in your view you could opt to add the `Spatie\\CookieConsent\\CookieConsentMiddleware` to your kernel:\n\nIn Laravel 11 open /bootstrap/app.php and register them there:\n\n```php\n    -\u003ewithMiddleware(function (Middleware $middleware) {\n        $middleware-\u003eappend(\\Spatie\\CookieConsent\\CookieConsentMiddleware::class);\n    })\n```\n\nIn Laravel 9 and 10 you can add them in app/Http/Kernel.php:\n\n```php\n// app/Http/Kernel.php\n\nclass Kernel extends HttpKernel\n{\n    protected $middleware = [\n        // ...\n        \\Spatie\\CookieConsent\\CookieConsentMiddleware::class,\n    ];\n\n    // ...\n}\n```\n\nThis will automatically add `cookie-consent::index` to the content of your response right before the closing body tag.\n\n## Notice\nWe are not lawyers and can't provide legal advice. Consult legal professionals what rules apply to your project.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security-related issues, please email freek@spatie.be instead of using the issue tracker.\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [Willem Van Bockstal](https://github.com/willemvb)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-cookie-consent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-cookie-consent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-cookie-consent/lists"}