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 Cookies Consent Laravel Package

scify/laravel-cookies-consent

A ready-to-use cookie consent solution for Laravel: display a customizable consent banner, manage cookie categories, log user consent, and restrict scripts until approval. Includes middleware, Blade views, config options, and multi-language support for GDPR-friendly compliance.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • scify/laravel-cookie-guard is a conventional Laravel package: a service provider, publishable config, publishable Blade components, a small set of routes, a published JS bundle, and translation files. It slots into the standard Laravel request lifecycle rather than requiring a separate service or build pipeline.
  • The consent flow is server-authoritative by design after this release: the browser posts a selection to POST /guard-settings/save, the server validates and persists it, and only then does the banner close. That is the right shape for a compliance-adjacent component — the audit trail and the UI state agree.
  • Scope is narrow and appropriate: cookie consent only. It does not attempt to be a tag manager, a CMP with vendor registries, or a consent log service. Teams needing a full CMP (vendor lists, consent receipts, TCF/IAB) will outgrow it; teams needing a GDPR-shaped banner for first-party cookies will not.
  • The web middleware grouping plus X-XSRF-TOKEN handling means it composes with Inertia, Livewire, and Turbo, which is where most modern Laravel apps actually live. That is a meaningful architectural improvement over a package that assumes full page reloads.

Integration feasibility

  • Low-to-moderate. Composer install, publish config/assets/translations, drop the Blade component into the layout. No Node build step required by the consumer — the bundle ships compiled.
  • The friction is concentrated in (a) re-publishing published assets and Blade components, and (b) the new root attributes (data-cookie-lifetime, data-cookie-categories, data-required-categories, data-csrf-token). Customised or forked banner markup must be manually reconciled, or erasure and lifetime silently stop working.
  • Translation publishing moved to lang/vendor/cookies_consent/, which uses Laravel's key-by-key merge. This is a genuine ergonomic win — you keep only overridden strings and inherit later fixes — but it is a one-time migration for anyone who published the old lang/vendor/scify/laravel-cookie-guard/ path.

Technical risk

  • Retroactive CSRF enforcement is the headline risk. POST /guard-settings/save was registered without middleware since the first release. Any in-house code that posts to that route (custom banners, SPA wrappers, test harnesses, QA scripts) will start receiving 419s. Laravel 13's same-origin exemption softens this, but it is not a guarantee across versions.
  • Silent degradation, not loud failure, is the second risk. Old published Blade markup does not error — it simply erases nothing and hardcodes 365 days. A team can upgrade, see a green build, and believe it is compliant while erasure is inert. This is the kind of defect that surfaces in a privacy audit, not in CI.
  • Compliance-bearing behaviour changed. Cookie erasure now walks host and parent domains down to the registrable one; required categories are excluded from rejection; cookie_lifetime now actually governs the browser-side consent cookie; 0 means session-only. Each of these changes what the product does with user data. None is a breaking API change, but all are behaviour changes a privacy owner should sign off on.
  • Locale rename se → sv breaks Swedish translations for any app configured with locale se. Fails soft (falls back to default strings), which makes it easy to miss.
  • Removed enabled config key. The notes state nothing read it, so risk is nominal — but any deployment that used it as a feature flag to disable the banner will find the banner now always active.
  • Prior versions were demonstrably non-compliant with their own documentation. The release frames itself as "behaves as documented in several places where it did not." That reframes the upgrade from "optional minor bump" to "we should audit what our current version actually does."
  • Mitigating signal: test coverage went from 45 to 60 Pest tests and 22 to 51 JS tests on node:test with 100% line coverage of the bundle, including a view-override test that boots the provider. For a package in the compliance path, that is the strongest evidence in these notes.

Key questions

  1. What is the officially supported Laravel and PHP version matrix? The notes reference Laravel 13 behaviour but do not state a floor.
  2. Was the missing CSRF middleware ever exploitable in a way that produced a false consent record, and is there guidance for teams that need to invalidate or re-collect consent captured under 5.0.x and earlier?
  3. How does the package determine "the registrable domain" during cookie erasure — public suffix list, config, or heuristic? This determines behaviour on multi-tenant and non-standard TLD deployments.
  4. Does the consent cookie carry any version or schema marker, so a future change to the stored shape can trigger re-consent rather than silent misinterpretation?
  5. Is SameSite=Lax sufficient for the embedded/iframe or cross-subdomain banner scenarios some customers run, or is that configurable?
  6. What is the deprecation commitment for the legacy translation directory beyond the stated v6 removal?
  7. Is there a documented consent-record retention story, or is the cookie the only artefact (i.e., no server-side log for audit purposes)?

Integration Approach

Stack fit

  • Best fit: server-rendered Laravel monoliths using Blade, including Inertia, Livewire, and Turbo front-ends. This release specifically hardens those paths.
  • Workable: Laravel applications with a lightly customised banner that are willing to re-publish and re-apply component overrides.
  • Poor fit: API-only or headless backends with a separate SPA on another origin (no Blade root, CSRF cookie story gets complicated); apps requiring IAB TCF, vendor-level consent, or consent receipts; multi-brand platforms needing per-tenant consent policies from a single install.
  • Watch: apps with a se locale, apps that disabled the banner via enabled, and apps with bespoke code posting to the save route.

Migration path

  • Treat this as a behaviour migration, not a patch bump, despite the "minor release, no breaking changes" framing.
  • Required steps, in order:
    1. php artisan vendor:publish --tag="cookies-consent-public" --force to refresh assets.
    2. Re-publish Blade components or hand-add the four new root attributes to any locally customised markup. Do not skip this — it is the difference between working and inert erasure.
    3. Move overridden translation strings to lang/vendor/cookies_consent/{locale}/messages.php and delete the legacy directory.
    4. If locale se is in use, switch to sv and verify string resolution.
    5. Audit any in-house code that posts to /guard-settings/save and add the CSRF token.
    6. Remove reliance on the enabled config key.
  • Where the package was never customised (config published, components untouched), the migration is genuinely small: publish assets, regenerate config if you want the removed key gone, verify.

Compatibility

  • Positive: config keys, routes, and Blade component names are unchanged. The old translation directory is still read with a log warning through v5.x, giving a full major cycle to migrate.
  • Negative/conditional: the new data-* root attributes are effectively required for correct behaviour but are not enforced by a runtime check or a console warning in old markup. Locale se is silently degraded. Custom save-route callers break on CSRF.
  • Unknown: Laravel/PHP version floor is not stated in the notes; confirm against composer.json before scheduling.

Sequencing

  1. Audit (week 1). Inventory every deployment: which version, whether components are published/customised, which locale codes are used, whether anything posts to the save route, whether enabled was relied on.
  2. Stage (week 1–2). Upgrade a non-production environment. Exercise the full consent lifecycle: accept all, reject optional, reject a single category, withdraw consent later, use_separate_page mode, hash-link entry, floating button via keyboard. Verify cookies are actually removed from the browser and from parent domains.
  3. Privacy/legal review (week 2). Have the DPO or privacy owner confirm the new erasure and lifetime semantics match the published cookie policy and the banner's own copy. This is the step most likely to slip and the one that matters most.
  4. Production rollout (week 3). Ship behind the normal release process. Because the change is client-side plus one route, a partial rollout or per-tenant flag is feasible if the app already has one.
  5. Post-deploy verification (week 3–4). Confirm across browsers that consent persists per cookie_lifetime, that Secure/SameSite attributes are present, and that erasure fires on rejection. Check logs for the legacy translation-directory warning and clear it.

Operational Impact

Maintenance

  • Healthy signals: active maintenance, an external code review driving most of the fixes, Rector/SonarCloud hygiene addressed, CI now runs on PRs against any branch, and materially expanded test suites on both sides of the stack. For a small package in a compliance path, that is better governance than average.
  • The translation-directory move reduces long-term maintenance for consumers (key-by-key merge means upstream string fixes arrive without re-publishing), but it is a one-time cost now.
  • Ongoing burden is low: no database, no background jobs, no external service dependency. The main recurring task is re-publishing assets on upgrade and re-checking custom markup against new root attributes.

Support

  • Upgrade notes are above average: explicit commands, explicit consequences of skipping the component re-publish, and a named grace period for the old translation path.
  • The gap is discoverability. A team that upgrades assets but not components gets no error and no warning — support will only hear about it when someone reports cookies surviving a rejection, or when a privacy review finds the lifetime is wrong.
  • Internal support cost is concentrated in two questions: "why did my custom save call start 419ing," and "why do cookies still exist after reject." Both should be pre-empted with an internal runbook rather than discovered.

Scaling

  • Runtime cost is negligible: one POST per consent decision, a short client-side loop over declared cookie names on rejection, and a banner render. No server-side state, no DB writes, no third-party calls. Scales with page views like any static asset.
  • The erasure loop walks declared cookies across host and parent domains. Cost grows with the number of declared cookies and domain levels, which is bounded and small in practice.
  • The one scaling caveat is organisational, not technical: consent state lives in a browser cookie, so there is no central store to query. Any future need for consent reporting or per-user audit will require an additional mechanism, not a configuration change.

Failure modes

Failure Symptom Detection Blast radius
Components not re-published Rejection erases nothing; lifetime ignores config None — silent Compliance; surfaces in audit
In-house save-route caller without CSRF 419 on consent save Server logs / browser console Banner stays open, consent not recorded
Locale se still configured English/default strings appear Visual QA Cosmetic-to-regulatory depending on jurisdiction
enabled relied upon Banner appears where it was suppressed Visual QA on next deploy User-visible regression
Save request fails (network/5xx) Banner remains open Client-side only User cannot dismiss; UX friction, but correct-by-design (no false consent)
Misconfigured cookie name/domains Erasure misses cookies on sibling subdomains Manual browser inspection Residual tracking after rejection
Non-standard TLD / multi-tenant host Registrable-domain calculation picks wrong scope Manual inspection Over- or under-erasure

Ramp-up

  • For a Laravel developer: under a day to install and wire up; a further half-day to exercise the consent lifecycle properly. The package is small and the published config is the documentation.
  • The real ramp-up cost is not engineering time, it is the privacy review. Budget for a DPO or legal reviewer to read the changed lifetime and erasure semantics against the cookie policy — roughly a half-day of their time, plus whatever remediation follows if the current version has been live and behaving differently from its documentation.
  • Recommended enablement artefact: a short internal runbook covering the four upgrade steps, the manual browser verification procedure for erasure, and the se→sv note. This is a package where the failure mode is silence, so the runbook is the control.
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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib