@@ -1212,6 +1212,58 @@ the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to
1212
1212
let Symfony manage the sessions itself using files to store the session
1213
1213
metadata.
1214
1214
1215
+ You can also configure the session handler with a DSN. For example:
1216
+
1217
+ .. configuration-block ::
1218
+
1219
+ .. code-block :: yaml
1220
+
1221
+ # config/packages/framework.yaml
1222
+ framework :
1223
+ session :
1224
+ # ...
1225
+ handler_id : ' redis://localhost'
1226
+ handler_id : ' %env(REDIS_URL)%'
1227
+ handler_id : ' %env(DATABASE_URL)%'
1228
+ handler_id : ' file://%kernel.project_dir%/var/sessions'
1229
+
1230
+ .. code-block :: xml
1231
+
1232
+ <!-- config/packages/framework.xml -->
1233
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
1234
+ <container xmlns =" http://symfony.com/schema/dic/services"
1235
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
1236
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
1237
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
1238
+ https://symfony.com/schema/dic/services/services-1.0.xsd
1239
+ http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
1240
+
1241
+ <framework : config >
1242
+ <framework : session enabled =" true"
1243
+ handler-id =" redis://localhost"
1244
+ handler-id =" %env(REDIS_URL)%"
1245
+ handler-id =" %env(DATABASE_URL)%"
1246
+ handler-id =" file://%kernel.project_dir%/var/sessions" />
1247
+ </framework : config >
1248
+ </container >
1249
+
1250
+ .. code-block :: php
1251
+
1252
+ // config/packages/framework.php
1253
+ $container->loadFromExtension('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
+ ]);
1262
+
1263
+ .. versionadded :: 4.4
1264
+
1265
+ The option to configure the session handler with a DSN was introduced in Symfony 4.4.
1266
+
1215
1267
If you prefer to make Symfony store sessions in a database read
1216
1268
:doc: `/doctrine/pdo_session_storage `.
1217
1269
0 commit comments