summaryrefslogtreecommitdiff
path: root/src/Http/SessionServiceProvider.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-30 19:31:14 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-30 19:33:14 +0200
commitb46207f91176cf944284c01c213d3f69075377a4 (patch)
tree3d04a46c84c8b66b2d5a56a851249fde80257e28 /src/Http/SessionServiceProvider.php
parent6187eed3bb08f200050a3078bd762b5731dfbe78 (diff)
parent0b0890f425ced27b2204a046296de4cccdac4eb8 (diff)
Merge remote-tracking branch 'MyIgel/session'
Diffstat (limited to 'src/Http/SessionServiceProvider.php')
-rw-r--r--src/Http/SessionServiceProvider.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Http/SessionServiceProvider.php b/src/Http/SessionServiceProvider.php
index 59121a3b..c2e09624 100644
--- a/src/Http/SessionServiceProvider.php
+++ b/src/Http/SessionServiceProvider.php
@@ -2,7 +2,9 @@
namespace Engelsystem\Http;
+use Engelsystem\Config\Config;
use Engelsystem\Container\ServiceProvider;
+use Engelsystem\Http\SessionHandlers\DatabaseHandler;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
@@ -38,7 +40,24 @@ class SessionServiceProvider extends ServiceProvider
return $this->app->make(MockArraySessionStorage::class);
}
- return $this->app->make(NativeSessionStorage::class, ['options' => ['cookie_httponly' => true]]);
+ /** @var Config $config */
+ $config = $this->app->get('config');
+ $sessionConfig = $config->get('session');
+
+ $handler = null;
+ switch ($sessionConfig['driver']) {
+ case 'pdo':
+ $handler = $this->app->make(DatabaseHandler::class);
+ break;
+ }
+
+ return $this->app->make(NativeSessionStorage::class, [
+ 'options' => [
+ 'cookie_httponly' => true,
+ 'name' => $sessionConfig['name'],
+ ],
+ 'handler' => $handler,
+ ]);
}
/**