Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed May 5, 2019
2 parents 3b6f9d6 + 6448abc commit 9af548e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
```

## Similar packages

* https://symfony.com/doc/current/components/http_foundation/sessions.html
* https://github.com/auraphp/Aura.Session
5 changes: 4 additions & 1 deletion src/SessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 9af548e

Please sign in to comment.