From 0f22c6aa4b1d109234a1a770b557a643430221ee Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 22 Feb 2020 19:48:21 +0100 Subject: [PATCH] [HttpFoundation] Allow to configure session handlers with DSN --- reference/configuration/framework.rst | 52 +++++++++++++++++++++++++++ session.rst | 6 ++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index f293c3a0a1a..1e26b240de6 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1243,6 +1243,58 @@ the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to let Symfony manage the sessions itself using files to store the session metadata. +You can also configure the session handler with a DSN. For example: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/framework.yaml + framework: + session: + # ... + handler_id: 'redis://localhost' + handler_id: '%env(REDIS_URL)%' + handler_id: '%env(DATABASE_URL)%' + handler_id: 'file://%kernel.project_dir%/var/sessions' + + .. code-block:: xml + + + + + + + + + + + .. code-block:: php + + // config/packages/framework.php + $container->loadFromExtension('framework', [ + 'session' => [ + // ... + 'handler_id' => 'redis://localhost', + 'handler_id' => '%env(REDIS_URL)%', + 'handler_id' => '%env(DATABASE_URL)%', + 'handler_id' => 'file://%kernel.project_dir%/var/sessions', + ], + ]); + +.. versionadded:: 4.4 + + The option to configure the session handler with a DSN was introduced in Symfony 4.4. + If you prefer to make Symfony store sessions in a database read :doc:`/doctrine/pdo_session_storage`. diff --git a/session.rst b/session.rst index 53cf435eb15..265a9820f8f 100644 --- a/session.rst +++ b/session.rst @@ -21,7 +21,7 @@ sessions, check their default configuration: # enables the support of sessions in the app enabled: true # ID of the service used for session storage. - # NULL = means that PHP's default session mechanism is used + # NULL means that Symfony uses PHP default session mechanism handler_id: null # improves the security of the cookies used for sessions cookie_secure: 'auto' @@ -42,7 +42,7 @@ sessions, check their default configuration: true, // ID of the service used for session storage - // NULL means that PHP's default session mechanism is used + // NULL means that Symfony uses PHP default session mechanism 'handler_id' => null, // improves the security of the cookies used for sessions 'cookie_secure' => 'auto', pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy