File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
components/http_foundation Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,8 @@ Example::
207
207
// ...
208
208
$session->clear();
209
209
210
+ .. _namespaced-attributes :
211
+
210
212
Namespaced Attributes
211
213
.....................
212
214
Original file line number Diff line number Diff line change @@ -201,5 +201,6 @@ More about Sessions
201
201
session/locale_sticky_session
202
202
session/php_bridge
203
203
session/proxy_examples
204
+ session/attribute_bag
204
205
205
206
.. _`HttpFoundation component` : https://symfony.com/components/HttpFoundation
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Sessions, Attribute Bag
3
+
4
+ Changing the Session Attribute Bag Provider
5
+ ===========================================
6
+
7
+ Symfony uses attribute bags to represent values stored in the session. It ships
8
+ with the default :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ AttributeBag `,
9
+ which stores key-value pairs, and the
10
+ :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Attribute\\ NamespacedAttributeBag `,
11
+ which allows you to :ref: `set and fetch values using character-separated paths <namespaced-attributes >`.
12
+
13
+ This is fully documented :doc: `in the component documentation </components/http_foundation/sessions >`.
14
+
15
+ Changing the Attribute Bag in Symfony
16
+ -------------------------------------
17
+
18
+ To use a different attribute bag for your sessions, override the service
19
+ definition. In this example, we switch the default ``AttributeBag `` to the
20
+ ``NamespacedAttributeBag ``:
21
+
22
+ .. configuration-block ::
23
+
24
+ .. code-block :: yaml
25
+
26
+ # config/services.yaml
27
+ session :
28
+ class : Symfony\Component\HttpFoundation\Session\Session
29
+ arguments : ["@session.storage", "@session.namespacedattributebag", "@session.flash_bag"]
30
+
31
+ session.namespacedattributebag :
32
+ class : Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag
33
+
You can’t perform that action at this time.
0 commit comments