Search by

mj-zana / session

mjnable

Server-side sessions and flash messages for Zana applications, stored in a PSR-16 cache

Package info

github.com/mjnable/zana-session

pkg:composer/mj-zana/session

Statistics

Installs: 21

Dependents: 2

Suggesters: 1

Stars: 0

Open Issues: 0

v2.5.0 2026-10-26 14:55 UTC

This package is auto-updated.

Last update: 2026-10-27 16:29:52 UTC


README

Server-side sessions and flash messages for Zana applications, stored in a PSR-16 cache.

composer require mj-zana/session

Register SessionServiceProvider (and a PSR-16 cache, such as mj-zana/cache). Add SessionMiddleware to the routes that need a session, such as a back office, or to http.middleware.

public function save(SessionInterface $session): ResponseInterface
{
    // …
    $session->flash('status', 'Published.');

    return $this->responses->redirect('/admin/posts', 303);
}
  • Untouched sessions cost nothing. A request that never writes the session stores nothing and sends no cookie, so public pages stay cacheable.
  • Cookie: HttpOnly, SameSite=Lax, Secure on HTTPS, scoped to the application's base path. Ids are 256 random bits.
  • Fixation: call regenerate() after login, and invalidate() at logout.
  • Flash messages last one request.
  • Lifetime: session.lifetime is the inactivity timeout, in seconds (default 7200). Each request restarts it.
  • Cookie name: session.cookie (default zana_session).

License

MIT