polymorphine/session

HTTP Request session context service handled by PSR-15 middleware

0.1.2 2022-10-05 01:42 UTC

This package is auto-updated.

Last update: 2024-11-05 06:05:57 UTC


README

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.