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.
delight-im/cookie wraps PHP's native cookie primitives behind a small, readable API and, critically, exposes SameSite attributes on PHP versions where the language runtime did not yet support them. That makes it a low-effort lever for reducing CSRF and cross-site request exposure without a broader auth rewrite.Secure, HttpOnly, SameSite, Path, Domain, expiry) is a prerequisite for GDPR/ePrivacy consent flows and for browser third-party-cookie deprecation readiness. If consent or tracking-adjacent features are on the roadmap, this is a concrete, cheap enabler.Adopt when:
setcookie() calls with inconsistent flags.SameSite support on an older PHP runtime (pre-7.3) and cannot upgrade the runtime on the roadmap timeline.Look elsewhere when:
Cookie facade plus EncryptCookies middleware and Symfony's HttpFoundation cookie objects already cover this ground, are maintained with the framework, and integrate with the response pipeline. Adding a parallel cookie library here creates two sources of truth for cookie policy — a real bug class.To executives: This is a small, free, permissively licensed PHP utility that lets us set browser cookies correctly and securely — including modern cross-site protections — with roughly a day of integration work rather than a sprint of custom code. It directly supports our security posture and any consent/privacy work already on the roadmap, at effectively zero licensing cost. The trade-off is maintenance risk: it is a small open-source project, so we would pin the version, vendor it into our codebase, and cover it with our own tests. If we are already on Laravel or Symfony, we should use the framework's built-in cookie handling instead and skip this entirely.
To engineering: Single-class, zero-dependency, MIT. Gives us consistent cookie attribute handling (Secure, HttpOnly, SameSite, Path, Domain, expiry) and backfills SameSite on older PHP runtimes. It is explicitly not a session manager, signer, or encryptor — we own token signing and consent state. Recommendation: adopt only in non-framework PHP entry points, vendor and pin it, and add a thin internal wrapper so we can swap the implementation later without touching call sites.
How can I help you explore Laravel packages today?