From 0bd5b631b4ad9132f70549984b097ad4ff56ac85 Mon Sep 17 00:00:00 2001 From: mzozulia Date: Tue, 9 Apr 2019 13:34:08 +0300 Subject: [PATCH 1/2] improved middleware --- src/Session/SessionMiddleware.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Session/SessionMiddleware.php b/src/Session/SessionMiddleware.php index 20e997f..3bdbf86 100644 --- a/src/Session/SessionMiddleware.php +++ b/src/Session/SessionMiddleware.php @@ -36,7 +36,10 @@ public function __construct(SessionInterface $session) */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next): ResponseInterface { - $this->session->start(); + if (!$this->session->isStarted()) { + $this->session->start(); + } + $response = $next($request, $response); $this->session->save(); From 6448abc986dadd9a25af2c3cddb11bf41356aea6 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Fri, 12 Apr 2019 08:43:41 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46c4214..93b461d 100644 --- a/README.md +++ b/README.md @@ -221,4 +221,9 @@ $app->group('/users', function () { $this->get('/login', \App\Action\UserLoginIndexAction::class); $this->get('/logout', \App\Action\UserLogoutAction::class); })->add(\Odan\Session\SessionMiddleware::class); -``` \ No newline at end of file +``` + +## Similar packages + +* https://symfony.com/doc/current/components/http_foundation/sessions.html +* https://github.com/auraphp/Aura.Session