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

Cookie Laravel Package

delight-im/cookie

Modern cookie management for PHP. A clean, secure API for setting, reading, and deleting cookies, with support for SameSite, HttpOnly and Secure flags, cookie prefixes, and session handling—helping you follow browser security best practices without boilerplate.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. delight-im/cookie is a framework-agnostic, dependency-free utility library whose surface is essentially two classes: a static Cookie facade over PHP's native setcookie() (adding first-class support for SameSite, HttpOnly, Secure, path/domain/expiry normalization, and a fluent option array), and a Session helper that centralizes session cookie hardening. That is a horizontal capability, not a vertical one — it does not participate in routing, DI, middleware, response objects, or PSR-7/PSR-15. For a Laravel codebase the architectural fit is therefore poor by default and good only at the periphery: it is a reasonable choice for cookie handling inside standalone PHP scripts, legacy non-framework services, CLI-invoked webhooks, or a package that must remain framework-independent. Inside a Laravel application it creates a second, parallel cookie authority alongside Illuminate\Contracts\Cookie\Factory, the EncryptCookies middleware, and AddQueuedCookiesToResponse, which is an architectural anti-pattern rather than an integration.

Integration feasibility. Mechanically trivial: composer require delight-im/cookie, MIT licensed, no transitive dependencies, no service provider needed, no published config. A spike is a single afternoon. The real feasibility question is why — Laravel already ships equivalent or superior semantics (config/session.php and the cookie config expose secure, http_only, same_site, plus encryption and signing via the web middleware group). Any integration must therefore be justified by a genuine out-of-framework boundary, not by preference.

Technical risk.

  • Security-sensitive surface. Cookie and session handling is directly in the auth/session-fixation blast radius. A small, single-maintainer library in this position demands a pinned version, a recorded commit SHA, and a read of the ~hundreds of lines of source before it touches anything session-bearing.
  • Ecosystem signal is weak. 166 stars and 0 dependents means almost no downstream pressure-testing; we would effectively be the first serious integrator and would absorb integration bugs ourselves.
  • Maintenance cadence. Single-author projects of this shape tend to have long quiet periods. There is no security policy, no CVE feed, and no LTS commitment to rely on.
  • Runtime drift. PHP 8.1+ deprecations (implicit nullable parameters, dynamic properties), PHP 8.2 readonly/${} string interpolation removals, and setcookie() signature behavior changes across 7.3/8.x are all live risks for a thin wrapper. The library also predates browsers' default SameSite=Lax behavior, so its explicit SameSite handling is the main value proposition — and the main thing to regression-test.
  • Global-state coupling. A static API writing through setcookie() interacts with output buffering and "headers already sent" in ways that are invisible to Laravel's response-centric model.

Key questions.

  1. What concrete requirement is unmet by illuminate/cookie + EncryptCookies? If the answer is "none," this is a decline.
  2. Do we have any non-Laravel PHP surface (legacy admin tool, standalone OAuth callback, WordPress-adjacent script, microservice) where a consistent cookie policy across frameworks is worth a shared dependency?
  3. Are we willing to fork and vendor it under our own namespace, accepting full ownership, rather than depend on an unmaintained upstream?
  4. What is our PHP version floor and upgrade cadence, and does the package's composer.json constraint cover it?
  5. Who signs off on the security review, and does that reviewer have capacity before the next release train?
  6. Is the intent adoption (dependency) or reference (read the source, adopt the SameSite/session-hardening patterns, write ~40 lines of in-house code)? The latter carries most of the value at a fraction of the TCO.

Integration Approach

Stack fit. Assume Laravel 9–11 with the standard web middleware group. The package fits only in the following lanes, in descending order of justification:

  • Out-of-framework PHP: standalone scripts, cron entrypoints, or a legacy app sharing a cookie domain with the Laravel product — here it provides a consistent SameSite/Secure/HttpOnly policy that raw setcookie() calls in scattered legacy files do not.
  • Framework-independent package code: if we publish an internal Composer package that must run under both Laravel and plain PHP, a tiny cookie abstraction is defensible.
  • Reference implementation: use it to audit and align our own cookie configuration; no runtime dependency. It does not fit inside request/response handling in a Laravel controller, middleware, or Blade flow.

Migration path. If adopted at the periphery: (1) install and pin an exact version; (2) wrap it behind our own thin interface (App\Support\CookiePolicy or equivalent) so the vendor class never appears in application code; (3) for the Laravel-facing side, implement Illuminate\Contracts\Cookie\Factory in the adapter so callers see a familiar contract and we retain a one-file swap-out; (4) migrate one legacy cookie at a time, lowest-risk first (theme/locale preference, referral attribution), never auth or session tokens on the first pass; (5) explicitly do not migrate session handling — leave Session unused unless a standalone service genuinely needs it, and if it does, isolate that service so its session cookie never collides with the Laravel app's cookie name or path. For the far more likely "reference only" route, the migration is a config change: audit config/session.php and config/cookies-equivalent values, set same_site, secure, and http_only explicitly per environment, and delete ad-hoc setcookie() calls in favor of the framework's queue.

Compatibility. Verify against our PHP matrix before anything else — check the php constraint in composer.json, then run the suite on our oldest and newest supported runtimes with E_ALL and deprecations promoted to errors. Confirm behavior when SameSite=None is requested without Secure (browsers discard the cookie silently; the library cannot save us). Confirm interaction with Laravel's EncryptCookies: cookies set through the package are plaintext; anything reading them from a Laravel request through $request->cookie() will either fail decryption or throw, and cookies set by Laravel will look like garbage to the package. That mismatch is the single most likely production surprise and must be designed out by scoping each jar to distinct cookie names and paths.

Sequencing.

  1. Week 1 — decision spike. Confirm whether a non-Laravel surface exists. If no, close the ticket with the audit findings as the deliverable.
  2. Week 2 — security and compatibility review. Source read, PHP-matrix run, SameSite/Secure behavior matrix across Safari/Chrome/Firefox.
  3. Week 3 — adapter + one low-risk cookie behind a feature flag, with a rollback that is a config toggle.
  4. Week 4 — observe. Cookie-set success rate, decrypt errors, 4xx on auth flows, "headers already sent" warnings.
  5. Only then consider a second cookie. Never sequence session or auth cookies in this rollout.

Operational Impact

Maintenance. The code itself is near-zero maintenance; the dependency is not. Budget an owner, a pinned version, and a standing quarterly check for upstream commits, PHP deprecation notices, and browser SameSite default changes. If the upstream goes quiet for 12+ months — the base rate for single-maintainer libraries — we either accept frozen code (fine, it is small) or fork it (then we own it fully). Either way, write down which one we chose. The 0-dependents figure means package managers and scanner tooling will tell us nothing; our own review is the control.

Support. No vendor, no SLA, no support contract. Internal support means "whoever read the source." That person must be named in the runbook, and the runbook must include the two failure signatures: cookie silently absent from the request, and cookie present but unserializable due to encryption mismatch. On-call triage for this should be a 15-minute decision tree, not an investigation.

Scaling. Technically a non-issue — it is a thin wrapper, no I/O, no state beyond PHP internals. The operational scaling risk is consistency: the moment two cookie mechanisms coexist, every new engineer has to know which cookies go through which path and why. That cognitive tax compounds with headcount far faster than it compounds with traffic. It also complicates CDN/edge cookie handling, domain consolidation, and any future move to a shared parent-domain session — exactly the sort of multi-brand or multi-app consolidation a TPM tends to get asked to plan.

Failure modes.

  • Silent no-op: setcookie() after output has started, producing a warning that a APP_DEBUG=false config suppresses. Symptom: intermittent login loops. Mitigation: assert headers-not-sent in the adapter and log loudly.
  • SameSite policy mismatch: third-party or cross-site flows (OAuth redirects, embedded checkout, iframe widgets) break when a cookie is Lax/Strict. This is the most common real-world regression from cookie work and is invisible to unit tests.
  • Dual-jar collision: same cookie name written by both Laravel and the package, with different path/domain/encryption. Symptom: stale or unreadable values that "fix themselves" on cache clear.
  • Session fixation / weak flags if the Session helper is adopted without matching the rest of the auth design (regeneration on privilege change, absolute and idle timeouts).
  • Upstream abandonment discovered only when a PHP upgrade breaks the package mid-release-train.
  • Domain/path misconfiguration between subdomains producing cookies that exist for one app and not another.

Ramp-up. Learning the API is under two hours for any PHP developer — the surface is small and the README is adequate for the happy path. The expensive part is the context: cookie scoping, SameSite semantics, encryption boundaries, and our own dual-stack policy. Budget roughly 1–2 days of onboarding for an engineer expected to touch this, most of it spent on our adapter and runbook rather than the vendor code. Document the decision ("used only for X, never for Y") next to the dependency — an undocumented parallel cookie mechanism is indistinguishable from an accident six months later.

Bottom line for prioritization. The low opportunity score is directionally right: this is a commodity capability that Laravel already delivers with encryption, signing, and middleware integration we would otherwise have to reconstruct. Recommend not adopting it as a runtime dependency in the Laravel application; recommend a short (≤2 day) audit against it to validate our SameSite/Secure/HttpOnly posture, plus a narrow dependency only if a concrete out-of-framework PHP surface exists that needs identical cookie semantics.

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.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager