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

Session Laravel Package

odan/session

Odan/session is a session middleware for Slim and other PSR-15 applications. It provides a clean SessionInterface for reading and writing session data, flash messages, configurable session handlers, and straightforward PHP-DI integration for Slim 4.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

odan/session is a thin, framework-agnostic wrapper over native PHP sessions with a PSR-15 middleware and a small object API (values, flash, segments). For a Laravel estate, that overlaps almost entirely with Illuminate\Session:

Capability odan/session Laravel native
Drivers/handlers Configurable native handlers (files, Redis, etc.) File, cookie, database, Redis, Memcached, DynamoDB, array
Flash data Yes, next-request lifecycle Yes, with _flash.old/_flash.new aging
Namespacing Session segments Dot-notation keys; Symfony SessionBagInterface via bridge
Middleware PSR-15 (Slim, Mezzio) StartSession, ShareErrorsFromSession, VerifyCsrfToken, AuthenticateSession
CSRF / encryption / auth coupling Not provided Provided and deeply integrated

Net: poor fit as a replacement inside the Laravel monolith — auth, CSRF, validation error sharing, and AuthenticateSession all depend on Illuminate\Session. Genuine fit exists in three narrow cases: (1) a Slim/Mezzio/PSR-7 service in the same estate that needs session parity, (2) an internal package that must run under both Laravel and non-Laravel hosts, (3) a front-controller or sidecar outside the Laravel HTTP kernel. The "segments" feature is the one capability without a clean Laravel equivalent, and it is not worth a second session stack on its own.

Integration feasibility

The blocking issue is two session owners. Both Laravel's StartSession and this package take ownership of session_start(), the session ID, and the session cookie. Co-residency produces double-start warnings, divergent IDs across the stack, header-ordering conflicts, and non-deterministic data loss. Second, Laravel's HTTP kernel is not a PSR-15 dispatcher; mounting the middleware requires a bridge or confining it to a PSR-15 application. Integration is feasible only behind an explicit adapter boundary — a SessionPort interface (get/set/flash/segment/regenerate/destroy) with one implementation over odan/session and one over Illuminate\Session, so call sites never touch either library directly.

Technical risk — medium-high

  • Runtime model. Native session_* functions are process-global and unsafe under Octane/Swoole/RoadRunner. If any candidate service runs on Octane, this is disqualifying for that service.
  • Supply chain. The repository URL is unknown — provenance, commit history, CI, and advisory history cannot be verified. 65 stars and a likely single maintainer implies bus factor 1. MIT/forkable and a very thin API surface are the mitigants.
  • Behavioral drift. Flash aging semantics, ID regeneration on privilege change, and GC configuration differ from Laravel's; migration will surface as duplicated or silently dropped flash messages.
  • Testability. Native sessions are awkward under PHPUnit; the team will need a fake or harness before CI can cover session behavior.

Key questions for the package owner

  1. Which services would actually consume this — any non-Laravel ones, or is this a substitute for Illuminate\Session?
  2. Does any target service run Octane, Swoole, or RoadRunner?
  3. Who owns the session cookie (domain, path, SameSite, Secure) when multiple apps share a parent domain?
  4. Is session payload encryption required? Laravel's cookie driver encrypts; native file/Redis handlers do not.
  5. How is CSRF handled in the non-Laravel consumer, given this package provides none?
  6. What is the concurrency model — is session locking enabled on the Redis handler, and what is the lock wait timeout?
  7. Can we obtain the canonical repository, a security contact, and a tagged release policy before adoption?
  8. What is the forced re-authentication cost if session payloads are not portable across the cutover?

Integration Approach

Stack fit

Context Verdict
Laravel monolith Do not adopt — use Illuminate\Session
Slim / Mezzio / PSR-15 service Adopt — this is the designed use case
Shared internal package targeting both Adopt behind a port interface
Octane / long-running workers Reject
CLI/queue workers Not applicable

Migration path

  1. Introduce the SessionPort abstraction first, with the existing Laravel implementation. This is valuable regardless of the outcome and caps the blast radius.
  2. For a Slim service moving toward Laravel: keep odan/session during the transition, add a second port implementation over Illuminate\Session, and switch at cutover by config, not by code change.
  3. Session payloads are not portable between implementations. Plan an explicit re-authentication window, or run dual-write with a read-preference flag for one release cycle, then drain.
  4. Decommission the old session cookie by renaming it and expiring the prior name with matching path/domain attributes to avoid orphaned cookies.

Compatibility checklist (verify before committing)

  • PHP version floor and ceiling vs. our standard image; test against the next PHP minor.
  • PSR-15 interface version (psr/http-server-middleware v1 vs v2) and our PSR-7 implementation (Nyholm, Guzzle).
  • Handler availability in our infrastructure — Redis session handler and its locking configuration.
  • Cookie parameter surface (SameSite, Secure, HttpOnly, lifetime) against our security baseline.
  • If bridging into Laravel: framework version compatibility and whether any maintained PSR-15 bridge is required.

Sequencing

  1. Discovery — inventory session usage per service; flag every Octane/Swoole consumer (exit criterion: no unknown consumers).
  2. Spike — one low-risk PSR-15 service, 2–3 engineer-days; validate flash lifecycle, segments, regeneration, and Redis handler behavior (exit: written findings, go/no-go).
  3. Port + adapter — 1–2 engineer-weeks including contract tests.
  4. Contract tests — fixation/regeneration, expiry, flash across two requests, segment isolation, concurrent-request locking.
  5. Rollout — non-Laravel services first; Laravel services default to no change.
  6. Decision gate — only if two or more services genuinely require a shared session layer does this become a platform commitment; otherwise it stays a tactical dependency.

Operational Impact

Maintenance

Pin to an exact version, mirror the repository internally (the upstream URL is unknown, so archive a clone now), and add it to the dependency review cadence. Assume we own patching: MIT and a ~200-line API surface mean a fork is cheap, but assign a named owner in the platform team. Include it in PHP upgrade rehearsals — session INI defaults and handler behavior shift across PHP minors.

Support

No commercial support and no evident security policy. Escalation path is internal. The mitigant is replaceability: the API is thin enough (get/set/flash/segment) that swapping to Symfony HttpFoundation session bags is a bounded effort, provided the port abstraction exists. Document that fallback in the runbook before rollout, not after.

Scaling

  • Native file sessions require sticky sessions or shared storage; neither is a good default at scale. Budget for a distributed handler from day one.
  • On Redis, enable session locking and tune the wait timeout — unbounded lock contention shows up as p95 latency spikes under concurrency, especially with parallel AJAX on the same session.
  • Set explicit TTL/GC; native GC is probabilistic and behaves differently across SAPIs (FPM vs. CLI), so "sessions never expire" incidents are common.
  • If any consumer uses the cookie handler, watch the 4 KB limit — segments make it easy to bloat.

Failure modes

Symptom Likely cause Mitigation
Users randomly logged out behind the LB Handler misconfigured, silently falling back to local files Config assertion at boot; health check that writes/reads a probe key
Flash messages duplicated or lost Mixed stacks, differing aging semantics Single session owner per request; contract tests at the boundary
session_start() warnings, broken state Started after headers sent, or double-start with Laravel Never co-mount; adapter enforces one owner
p95 latency spikes Session lock contention on Redis Locking config + timeout; reduce parallel same-session requests
Session fixation exposure ID not regenerated on privilege change Explicit regeneration in the auth flow; test it
Silent breakage on framework/PHP upgrade Untested transitive API assumptions Pin + upgrade rehearsal + contract suite

Ramp-up

The library is small enough to learn in a day, but the team's muscle memory is Laravel facades and session() helpers — PSR-15 middleware wiring and the segment API add friction out of proportion to the code size. Expect 1–2 engineer-weeks for the spike, adapter, and contract tests, plus 2–3 days to build session test isolation into CI. Add lightweight observability before launch: active session count, handler error rate, lock wait time, and a canary on flash-message anomalies.

Recommendation: conditional adoption as an interop dependency for non-Laravel PSR-15 services, gated on repository provenance being obtainable and on no Octane consumers. Do not adopt it as a session layer for Laravel applications; the overlap is near-total and the integration risk is asymmetric.

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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource