@@ -73,6 +73,7 @@ easily serve as examples if you wish to write your own.
73
73
74
74
* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ PdoSessionHandler `
75
75
* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MemcachedSessionHandler `
76
+ * :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MigratingSessionHandler `
76
77
* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ RedisSessionHandler `
77
78
* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ MongoDbSessionHandler `
78
79
* :class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ NullSessionHandler `
@@ -87,6 +88,32 @@ Example usage::
87
88
$sessionStorage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo));
88
89
$session = new Session($sessionStorage);
89
90
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
+
90
117
Configuring PHP Sessions
91
118
~~~~~~~~~~~~~~~~~~~~~~~~
92
119
0 commit comments