@@ -1243,6 +1243,58 @@ the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to
1243
1243
let Symfony manage the sessions itself using files to store the session
1244
1244
metadata.
1245
1245
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
+
1246
1298
If you prefer to make Symfony store sessions in a database read
1247
1299
:doc: `/doctrine/pdo_session_storage `.
1248
1300
0 commit comments