@@ -1206,6 +1206,58 @@ the native PHP session mechanism. Set it to ``'session.handler.native_file'`` to
1206
1206
let Symfony manage the sessions itself using files to store the session
1207
1207
metadata.
1208
1208
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
+
1209
1261
If you prefer to make Symfony store sessions in a database read
1210
1262
:doc: `/doctrine/pdo_session_storage `.
1211
1263
0 commit comments