diff --git a/app/config/config.yml b/app/config/config.yml index ba6ace5db..4b1c2a604 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -332,9 +332,8 @@ framework: default_locale: "%locale%" trusted_hosts: ~ session: - # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id - storage_id: session.storage.php_bridge - handler_id: ~ + # https://symfony.com/doc/4.x/session/database.html#store-sessions-in-a-relational-database-mariadb-mysql-postgresql + handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler fragments: ~ http_method_override: true assets: ~ diff --git a/app/config/services.yml b/app/config/services.yml index a7f4ed75e..500d5d19f 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -14,6 +14,12 @@ services: _defaults: public: true + Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler: + public: false + arguments: + - 'mysql:host=%database_host%;port=%database_port%;dbname=%database_name%' + - { db_username: '%database_user%', db_password: '%database_password%' } + AppBundle\Controller\Event\: resource: '../../sources/AppBundle/Controller/Event/*' autowire: true diff --git a/db/migrations/20240106213200_sessions.php b/db/migrations/20240106213200_sessions.php new file mode 100644 index 000000000..573670a9d --- /dev/null +++ b/db/migrations/20240106213200_sessions.php @@ -0,0 +1,20 @@ +execute($sql); + } +} diff --git a/htdocs/app.php b/htdocs/app.php index 0f8f3d655..db685d027 100644 --- a/htdocs/app.php +++ b/htdocs/app.php @@ -19,8 +19,6 @@ exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); } - session_start(); - /** @var \Composer\Autoload\ClassLoader $loader */ $loader = require __DIR__.'/../vendor/autoload.php'; Debug::enable(); @@ -34,8 +32,6 @@ /** @var \Composer\Autoload\ClassLoader $loader */ $loader = require __DIR__.'/../vendor/autoload.php'; - session_start(); - $kernel = new AppKernel('prod', false); } diff --git a/htdocs/include/prepend.inc.php b/htdocs/include/prepend.inc.php index ef8c2170a..09206b26e 100644 --- a/htdocs/include/prepend.inc.php +++ b/htdocs/include/prepend.inc.php @@ -3,8 +3,6 @@ // Initialisation ob_start(); -session_start(); - // Inclusion de l'autoload de composer require_once dirname(__FILE__) . '/../../vendor/autoload.php'; diff --git a/htdocs/pages/planete/app.php b/htdocs/pages/planete/app.php index 4169d0a70..ccee78e7c 100644 --- a/htdocs/pages/planete/app.php +++ b/htdocs/pages/planete/app.php @@ -28,8 +28,6 @@ exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); } - session_start(); - /** @var ClassLoader $loader */ $loader = require __DIR__.'/../../../vendor/autoload.php'; Debug::enable(); @@ -43,8 +41,6 @@ /** @var ClassLoader $loader */ $loader = require __DIR__.'/../../../vendor/autoload.php'; - session_start(); - $kernel = new PlaneteAppKernel('prod', false); } diff --git a/planete/app/config/config.yml b/planete/app/config/config.yml index 35620f68b..a3e064429 100644 --- a/planete/app/config/config.yml +++ b/planete/app/config/config.yml @@ -19,8 +19,8 @@ framework: default_locale: "%locale%" trusted_hosts: ~ session: - storage_id: session.storage.php_bridge - handler_id: ~ + # https://symfony.com/doc/4.x/session/database.html#store-sessions-in-a-relational-database-mariadb-mysql-postgresql + handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler fragments: ~ http_method_override: true assets: ~ diff --git a/planete/app/config/services.yml b/planete/app/config/services.yml index c216fac95..af8486836 100644 --- a/planete/app/config/services.yml +++ b/planete/app/config/services.yml @@ -4,6 +4,12 @@ services: autowire: true autoconfigure: true + Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler: + public: false + arguments: + - 'mysql:host=%database_host%;port=%database_port%;dbname=%database_name%' + - { db_username: '%database_user%', db_password: '%database_password%' } + AppBundle\LegacyModelFactory: ~ PlanetePHP\: diff --git a/sources/Afup/Bootstrap/Http.php b/sources/Afup/Bootstrap/Http.php index 696d3fc03..707d65054 100644 --- a/sources/Afup/Bootstrap/Http.php +++ b/sources/Afup/Bootstrap/Http.php @@ -26,9 +26,6 @@ if (ob_get_level() === 0) { ob_start(); } -if (session_status() === PHP_SESSION_NONE) { - session_start(); -} // mise à jour des paramètrage PHP en fonction de la configuration