mini\Session\SessionMiddleware class

Documentation

PSR-15 middleware that adds session cookies to responses

This middleware runs AFTER the request is handled, checking if the session needs a cookie set (new session, regenerated ID, or destroy). If so, it adds the Set-Cookie header to the PSR-7 response.

This approach:

  • Integrates with PSR-7 response handling
  • Works in Swoole/ReactPHP/phasync (no setcookie() calls)
  • Is testable (no direct header manipulation)

Inheritance

Implements: Psr\Http\Server\MiddlewareInterface

Methods (4)

Documentation missing

Format cookie data as Set-Cookie header value

Check if the current request is over HTTPS

Apply cache control headers based on session.cache_limiter

Source

src/Session/SessionMiddleware.php:24-166