@@ -73,6 +73,7 @@ easily serve as examples if you wish to write your own.
7373
7474* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ PdoSessionHandler `
7575* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MemcachedSessionHandler `
76+ * :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MigratingSessionHandler `
7677* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ RedisSessionHandler `
7778* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MongoDbSessionHandler `
7879* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ NullSessionHandler `
@@ -87,6 +88,32 @@ Example usage::
8788 $sessionStorage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo));
8889 $session = new Session($sessionStorage);
8990
91+ Migrating Between Save Handlers
92+ -------------------------------
93+
94+ .. versionadded :: 4.1
95+ The ``MigratingSessionHandler `` class was introduced in Symfony 4.1.
96+
97+ If your application changes the way sessions are stored, use the
98+ :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MigratingSessionHandler `
99+ to migrate between old and new save handlers without losing session data.
100+
101+ This is the recommended migration workflow:
102+
103+ #. Switch to the migrating handler, with your new handler as the write-only one.
104+ The old handler behaves as usual and sessions get written to the new one::
105+
106+ $sessionStorage = new MigratingSessionHandler($oldSessionStorage, $newSessionStorage);
107+
108+ #. After your session gc period, verify that the data in the new handler is correct.
109+ #. Update the migrating handler to use the old handler as the write-only one, so
110+ the sessions will now be read from the new handler. This step allows easier rollbacks::
111+
112+ $sessionStorage = new MigratingSessionHandler($newSessionStorage, $oldSessionStorage);
113+
114+ #. After verifying that the sessions in your application are working, switch
115+ from the migrating handler to the new handler.
116+
90117Configuring PHP Sessions
91118~~~~~~~~~~~~~~~~~~~~~~~~
92119
0 commit comments