Skip to content

Commit

Permalink
Added session lifetime config [SLE-192]
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgfeller committed Nov 24, 2023
1 parent c25542c commit 56430c0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
6 changes: 0 additions & 6 deletions config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Nyholm\Psr7\Factory\Psr17Factory;
use Odan\Session\Middleware\SessionStartMiddleware;
use Odan\Session\PhpSession;
use Odan\Session\SessionInterface;
use Odan\Session\SessionManagerInterface;
Expand Down Expand Up @@ -150,14 +149,9 @@

SessionInterface::class => function (ContainerInterface $container) {
$options = $container->get('settings')['session'];

return new PhpSession($options);
},

SessionStartMiddleware::class => function (ContainerInterface $container) {
return new SessionStartMiddleware($container->get(SessionInterface::class));
},

BasePathMiddleware::class => function (ContainerInterface $container) {
return new BasePathMiddleware($container->get(App::class));
},
Expand Down
5 changes: 3 additions & 2 deletions config/env/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@

// Session
$settings['session'] = [
'name' => 'webapp',
'cache_expire' => 0,
'name' => 'slim-example-project',
// 5h session lifetime
'lifetime' => 18000, // Time in seconds
];

$settings['logger'] = [
Expand Down
3 changes: 1 addition & 2 deletions config/middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
// but after PhpViewExtensionMiddleware as it needs the user id)
$app->add(\App\Application\Middleware\UserNetworkSessionDataMiddleware::class);

// Has to be after PhpViewExtensionMiddleware to be called before on request as session is used in php-view extension
// LocaleMiddleware the same, session has to be established. All middlewares that need session must go above this line
// Has to be after every middleware that needs a started session (LIFO)
$app->add(SessionStartMiddleware::class);

// Cors middleware has to be before routing so that it is performed after routing (LIFO)
Expand Down

0 comments on commit 56430c0

Please sign in to comment.