Skip to content

Commit 58c09e9

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: [HttpFoundation] Allow to configure session handlers with DSN
2 parents 3891fad + be93a44 commit 58c09e9

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

reference/configuration/framework.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,58 @@ the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to
12061206
let Symfony manage the sessions itself using files to store the session
12071207
metadata.
12081208

1209+
You can also configure the session handler with a DSN. For example:
1210+
1211+
.. configuration-block::
1212+
1213+
.. code-block:: yaml
1214+
1215+
# config/packages/framework.yaml
1216+
framework:
1217+
session:
1218+
# ...
1219+
handler_id: 'redis://localhost'
1220+
handler_id: '%env(REDIS_URL)%'
1221+
handler_id: '%env(DATABASE_URL)%'
1222+
handler_id: 'file://%kernel.project_dir%/var/sessions'
1223+
1224+
.. code-block:: xml
1225+
1226+
<!-- config/packages/framework.xml -->
1227+
<?xml version="1.0" encoding="UTF-8" ?>
1228+
<container xmlns="http://symfony.com/schema/dic/services"
1229+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1230+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1231+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1232+
https://symfony.com/schema/dic/services/services-1.0.xsd
1233+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1234+
1235+
<framework:config>
1236+
<framework:session enabled="true"
1237+
handler-id="redis://localhost"
1238+
handler-id="%env(REDIS_URL)%"
1239+
handler-id="%env(DATABASE_URL)%"
1240+
handler-id="file://%kernel.project_dir%/var/sessions"/>
1241+
</framework:config>
1242+
</container>
1243+
1244+
.. code-block:: php
1245+
1246+
// config/packages/framework.php
1247+
$container->loadFromExtension('framework', [
1248+
'session' => [
1249+
// ...
1250+
'handler_id' => 'redis://localhost',
1251+
'handler_id' => '%env(REDIS_URL)%',
1252+
'handler_id' => '%env(DATABASE_URL)%',
1253+
'handler_id' => 'file://%kernel.project_dir%/var/sessions',
1254+
],
1255+
]);
1256+
1257+
.. versionadded:: 4.4
1258+
1259+
The option to configure the session handler with a DSN was introduced in Symfony 4.4.
1260+
12091261
If you prefer to make Symfony store sessions in a database read
12101262
:doc:`/doctrine/pdo_session_storage`.
12111263

session.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sessions, check their default configuration:
2121
# enables the support of sessions in the app
2222
enabled: true
2323
# ID of the service used for session storage.
24-
# NULL = means that PHP's default session mechanism is used
24+
# NULL means that Symfony uses PHP default session mechanism
2525
handler_id: null
2626
# improves the security of the cookies used for sessions
2727
cookie_secure: 'auto'
@@ -42,7 +42,7 @@ sessions, check their default configuration:
4242
<!--
4343
enabled: enables the support of sessions in the app
4444
handler-id: ID of the service used for session storage
45-
NULL means that PHP's default session mechanism is used
45+
NULL means that Symfony uses PHP default session mechanism
4646
cookie-secure and cookie-samesite: improves the security of the cookies used for sessions
4747
-->
4848
<framework:session enabled="true"
@@ -60,7 +60,7 @@ sessions, check their default configuration:
6060
// enables the support of sessions in the app
6161
'enabled' => true,
6262
// ID of the service used for session storage
63-
// NULL means that PHP's default session mechanism is used
63+
// NULL means that Symfony uses PHP default session mechanism
6464
'handler_id' => null,
6565
// improves the security of the cookies used for sessions
6666
'cookie_secure' => 'auto',

0 commit comments

Comments
 (0)