From 994bd775ea14dc5e7dab72f042bb12291d7aa3a3 Mon Sep 17 00:00:00 2001 From: Brock H Caldwell Date: Wed, 30 Apr 2025 18:13:19 -0500 Subject: [PATCH] fix: stores session in DB --- config/packages/framework.yaml | 6 ++--- config/services.yaml | 4 ++++ migrations/Version20250430231033.php | 35 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 migrations/Version20250430231033.php diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 4766a7a..681efda 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -2,13 +2,13 @@ framework: secret: '%env(APP_SECRET)%' - # Note that the session will be started ONLY if you read or write from it. - session: true - trusted_proxies: 'private_ranges' # trust *all* "X-Forwarded-*" headers trusted_headers: [ 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix' ] + session: + handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler + #esi: true #fragments: true diff --git a/config/services.yaml b/config/services.yaml index f928b29..37bb078 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -23,3 +23,7 @@ services: # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones App\Download\Downloader\DownloaderInterface: "@App\\Download\\Downloader\\ProcessDownloader" + + Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler: + arguments: + - '%env(DATABASE_URL)%' diff --git a/migrations/Version20250430231033.php b/migrations/Version20250430231033.php new file mode 100644 index 0000000..d363bb6 --- /dev/null +++ b/migrations/Version20250430231033.php @@ -0,0 +1,35 @@ +addSql(<<<'SQL' + CREATE TABLE sessions (sess_id VARBINARY(128) NOT NULL, sess_data LONGBLOB NOT NULL, sess_lifetime INT UNSIGNED NOT NULL, sess_time INT UNSIGNED NOT NULL, INDEX sess_lifetime_idx (sess_lifetime), PRIMARY KEY(sess_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_bin` ENGINE = InnoDB + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + DROP TABLE sessions + SQL); + } +}