Skip to content

HTTP Request session context service handled by PSR-15 middleware

License

Notifications You must be signed in to change notification settings

polymorphine/session

Repository files navigation

Polymorphine/Session

Latest stable release Build status Coverage status PHP version LICENSE

HTTP Request session context service handled by PSR-15 middleware

Installation with Composer

composer require polymorphine/session

How it works?

In procedural code you would have to call session_start() to allow access to superglobal $_SESSION array. This library also requires initialisation phase, but it is achieved with (PSR-15) middleware. Request going through this middleware will trigger SessionContext, and SessionStorage will become available.

The session storage is not superglobal anymore, and it can be passed explicitly into objects that require access to its data. The downside is that it cannot be instantiated directly before request processing is started, so lazy initialisation is necessary one way or another.