10000 minor #13227 [HttpFoundation] Allow to configure session handlers wit… · symfony/symfony-docs@be93a44 · GitHub
[go: up one dir, main page]

Skip to content

Commit be93a44

Browse files
committed
minor #13227 [HttpFoundation] Allow to configure session handlers with DSN (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch (closes #13227). Discussion ---------- [HttpFoundation] Allow to configure session handlers with DSN Fix #12566. Commits ------- 0f22c6a [HttpFoundation] Allow to configure session handlers with DSN
2 parents c672a84 + 0f22c6a commit be93a44

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
@@ -1243,6 +1243,58 @@ the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to
12431243
let Symfony manage the sessions itself using files to store the session
12441244
metadata.
12451245

1246+
You can also configure the session handler with a DSN. For example:
1247+
1248+
.. configuration-block::
1249+
1250+
.. code-block:: yaml
1251+
1252+
# config/packages/framework.yaml
1253+
framework:
1254+
session:
1255+
# ...
1256+
handler_id: 'redis://localhost'
1257+
handler_id: '%env(REDIS_URL)%'
1258+
handler_id: '%env(DATABASE_URL)%'
1259+
handler_id: 'file://%kernel.project_dir%/var/sessions'
1260+
1261+
.. code-block:: xml
1262+
1263+
<!-- config/packages/framework.xml -->
1264+
<?xml version="1.0" encoding="UTF-8" ?>
1265+
<container xmlns="http://symfony.com/schema/dic/services"
1266+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1267+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1268+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1269+
https://symfony.com/schema/dic/services/services-1.0.xsd
1270+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1271+
1272+
<framework:config>
1273+
<framework:session enabled="true"
1274+
handler-id="redis://localhost"
1275+
handler-id="%env(REDIS_URL)%"
1276+
handler-id="%env(DATABASE_URL)%"
1277+
handler-id="file://%kernel.project_dir%/var/sessions"/>
1278+
</framework:config>
1279+
</container>
1280+
1281+
.. code-block:: php
1282+
1283+
// config/packages/framework.php
1284+
$container->loadFromExtension('framework', [
1285+
'session' => [
1286+
// ...
1287+
'handler_id' => 'redis://localhost',
1288+
'handler_id' => '%env(REDIS_URL)%',
1289+
'handler_id' => '%env(DATABASE_URL)%',
1290+
'handler_id' => 'file://%kernel.project_dir%/var/sessions',
1291+
],
1292+
]);
1293+
1294+
.. versionadded:: 4.4
1295+
1296+
The option to configure the session handler with a DSN was introduced in Symfony 4.4.
1297+
12461298
If you prefer to make Symfony store sessions in a database read
12471299
:doc:`/doctrine/pdo_session_storage`.
12481300

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)
0