scify/laravel-cookie-guard
Laravel Cookie Guard is a configurable cookie consent package for Laravel. It adds a GDPR-friendly banner, lets visitors accept or reject cookie categories, remembers their choices, and helps load scripts conditionally through simple Blade helpers and middleware.
web middleware on POST /guard-settings/save meant the CSRF token sent by the JavaScript was never checked since the first release. This is a real vulnerability in a state-changing consent endpoint. Upgrading is a risk-reduction decision, not a nice-to-have.cookie_lifetime, including session-only consent at 0), fixes use_separate_page so optional categories are actually stored as accepted, and makes “Reject optional” respect every required category. That improves the accuracy of the consent record you may need to rely on.XSRF-TOKEN as X-XSRF-TOKEN and adding data-csrf-token fallbacks makes the package usable on Inertia, Livewire, and Turbo pages that never fully reload. This widens the set of products where the package is a viable default.data-cookie-lifetime, data-cookie-categories, data-required-categories, data-csrf-token), otherwise erasure does nothing and lifetime falls back to 365 days. Swedish apps using locale se must move to sv. Published translations must move to lang/vendor/cookies_consent/{locale}/messages.php; the old path is read with a log warning until v6. These are migration items that should be scheduled and verified.Consider it when:
lang/vendor/cookies_consent/ path.Look elsewhere when:
/guard-settings/save; this release requires that work.enabled config or the old lang/se Swedish locale path and you cannot make the corresponding config and locale changes.For executives: v5.1.0 is a minor release with a security fix and meaningful consent-correctness improvements. The package’s consent-save endpoint was previously missing CSRF protection; this release fixes that and should be taken. It also makes the banner honour the configured consent lifetime, erases rejected cookies as documented, and fixes the separate-page consent flow where optional categories were not being stored as accepted. There is no new vendor cost and no replacement of the consent approach. The upgrade requires re-publishing assets and a short configuration/translation check, so it should be scheduled as a small maintenance release rather than treated as a drop-in composer update. From a risk perspective, the CSRF fix and the more reliable consent record are the reasons to prioritise it.
For engineering: Minor release, no breaking changes to Blade components, routes, or config keys, but there are operational upgrade steps: re-publish cookies-consent-public; re-publish or patch published components with the new data-* attributes; move translation overrides to lang/vendor/cookies_consent/{locale}/messages.php; change locale se to sv if used; remove reliance on the removed enabled config; and send a CSRF token if your own code posts to /guard-settings/save. The old translation path still works with a log warning until v6. Test coverage is substantially improved, including 100% line coverage of the JavaScript bundle.
For product/legal reviewers: The release closes gaps between documented and actual behaviour: consent lifetime now follows cookie_lifetime (0 means session-only), rejected categories erase declared cookies on the host and parent domains down to the registrable domain, and the banner stays open until the server confirms the save. The consent payload is validated server-side: one boolean per configured category plus locale; unknown keys are dropped; non-booleans return 422; required categories are always stored as accepted. The main caveats are migration-related, not conceptual: published component overrides must be updated to get erasure and lifetime behaviour, and the Swedish locale identifier changed from se to sv.
How can I help you explore Laravel packages today?