Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Cookie Guard Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. Laravel-native package: service provider, config file, Blade components, published views/assets/translations, and a single POST /guard-settings/save route. It fits server-rendered Laravel monoliths (Blade, Livewire, Inertia, Turbo) well and does not fit headless/API-only or non-Laravel front ends. The critical architectural property is that it is designed to be forked at install time: views, assets, and translations are published into our repo. Upstream fixes reach us only when we re-publish or hand-merge, so the package's correctness is partly a function of our publishing discipline, not just the vendor's.

Integration feasibility. The Composer bump is trivial; the real work is the four documented upgrade steps. Estimated 3–6 dev hours plus QA, plus a privacy/legal review that is not optional here. Feasible within a normal sprint.

Technical risk: medium. v5.1.0 is labelled minor, but several changes are behaviorally breaking for existing deployments:

  1. CSRF enforcement on a previously unprotected route. POST /guard-settings/save ran without middleware since the first release, so the CSRF token the JS sent was never validated. It is now inside the web group. Any first-party code posting to that route breaks until it sends a token. Separately, this is a years-old CSRF-exempt write endpoint in production — worth a line in the security register and a log review, not just a version bump.
  2. Consent cookie lifetime now follows cookie_lifetime. It was hardcoded to 30 days; config said 365; the banner text claimed a year. Consent that quietly expired monthly will now persist up to a year. That is a compliance-relevant change requiring privacy sign-off, not a code-review sign-off.
  3. Cookie erasure is now genuinely destructive. Rejecting or withdrawing a category erases cookies named in that category on the host and every parent domain down to the registrable domain. Blast radius is any app cookie whose name collides with a declared category name, on any subdomain. Subdomain-per-tenant or shared-parent-domain estates must audit the cookie name lists before enabling.
  4. Availability coupling. The banner now hides only after the server confirms the save. Combined with strict CSRF and payload validation (422 on non-boolean, unknown keys dropped), a misconfigured deployment produces a banner that never closes and blocks the UI — a louder failure than the old silent one, but still a page-blocking one.
  5. Published-markup drift. With the pre-5.1 markup the new JS "erases nothing and uses 365 days." That is partial, silent degradation in the most likely real-world upgrade path (assets republished, views not).
  6. Claimed non-breaking, actually breaking: removal of the enabled config key and the se → sv locale move both break callers despite the "no breaking changes" framing. SemVer discipline is loose; treat minor releases as needing a changelog read.
  7. Route now in web implies session start on that endpoint — check route caching and any stateless/API consumer assumptions.

Assessment: upgrade recommended — it fixes a real CSRF hole and several correctness bugs — but it is not a drop-in patch. Gate it on a staging verification of the erasure behavior and the CSRF path.

Key questions.

  • Is consent state stored only in a cookie, or is there a server-side record? (Determines auditability and the erasure blast radius.)
  • Which of our cookies share names with declared category cookies, and do we run on shared parent domains?
  • Are Blade components published in our repo? If so, who owns merging the four new root data-* attributes?
  • Does any app code read the removed enabled key, the se locale, or the removed cookies_consent_selection cookie?
  • Does the 30-day → cookie_lifetime change alter our documented consent renewal period?
  • Is Secure cookie flagging correct behind our load balancer (TrustProxies / X-Forwarded-Proto)?
  • Should /guard-settings/save be rate-limited at the edge given it is now a session-bearing endpoint?

Integration Approach

Stack fit. Native to our Laravel version range; the notes reference Laravel 13-specific CSRF behavior alongside older releases, so confirm our version's expectation (token required vs. same-origin accepted) before testing. No new runtime dependencies; the JS still ships as a published bundle.

Migration path (in order).

  1. Read the changelog against our published artifacts — inventory whether views, assets, and translations are published, and where translations currently live.
  2. composer require / update to v5.1.0 in a branch; do not deploy assets yet.
  3. Grep the codebase for: posts to /guard-settings/save, cookies_consent_selection, cookieConsent, enabled config reads, locale se.
  4. Re-publish assets: php artisan vendor:publish --tag="cookies-consent-public" --force. Diff before committing — --force overwrites local customizations.
  5. Re-publish Blade components, or hand-merge the four new root attributes (data-cookie-lifetime, data-cookie-categories, data-required-categories, data-csrf-token). Skipping this silently disables erasure and pins 365-day consent.
  6. Move modified translation strings to lang/vendor/cookies_consent/{locale}/messages.php; delete the old lang/vendor/scify/laravel-cookie-guard/ directory.
  7. Add CSRF token sending (X-XSRF-TOKEN or X-CSRF-TOKEN) to any first-party POST to the save route.
  8. Verify cookie name lists in config against our actual cookie inventory; confirm required categories match the legal classification.

Compatibility and sequencing. Ship to staging first with a real browser matrix; the changed surfaces are JS-driven. Test explicitly: use_separate_page mode (Accept all / Reject optional previously stored nothing), hash-navigation to #consent-settings, keyboard activation of the floating button, and banner behavior on a forced 422/500 from the save endpoint. Run the erasure test on a subdomain to confirm parent-domain deletion does not remove cookies we need. Sequence the privacy review before production, in parallel with staging QA. Rollback is a Composer pin plus asset revert — keep both in the same commit for a clean revert.

Operational Impact

Maintenance. Low code footprint, but real fork-maintenance: published views and translations are ours to reconcile on every release. Budget a recurring ~2–4 hours per release for diff-and-merge. Watch two deprecations clocking toward v6: the legacy translation directory (read with a log warning until v6) and the removal of the pre-v3 cookieConsent erasure handler — neither is a problem today, both are calendar items.

Support. Single-maintainer open-source project on GitHub, MIT licensed. No commercial support path; escalation is upstream issues and patches. The release shows healthy signals — external code review, contributor PRs, test count up from 45→60 Pest and 22→51 JS with 100% JS line coverage — which raises confidence in the JS correctness fixes specifically, since that is where the bugs were.

Scaling. Stateless: consent lives in a first-party cookie, so no database or cache tier and no horizontal-scaling constraint. The one per-user cost is a single POST on consent decisions; negligible, but it is now a session-bearing write endpoint, so add edge rate limiting and alerting on 4xx/5xx spikes as a proxy for broken clients.

Failure modes.

  • Save endpoint rejects (CSRF mismatch, 422 validation, 5xx) → banner never hides, blocks interaction. Highest-severity new failure mode; needs a monitored error signal and a documented manual escape.
  • Assets republished without views → erasure silently disabled, lifetime silently 365 days. Detect by asserting the new data-* attributes are present in rendered HTML in a smoke test.
  • Cookie name collision → rejection erases a cookie an unrelated feature depends on, across subdomains.
  • Proxy/TLS misconfiguration → consent cookie written without Secure.
  • Log noise from the legacy translation path until the directory is deleted.

Ramp-up. Low for a mid-level Laravel developer: one to two hours to read the package, a half-day to run the upgrade safely. The non-obvious skill is not PHP — it is reading the cookie inventory and the erasure semantics correctly, which is a privacy-engineering task. Assign a named owner for the cookie-list review; do not let it fall to whoever runs composer update.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus