You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$sessionStorage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo));
88
89
$session = new Session($sessionStorage);
89
90
91
+
Migrating Between Save Handlers
92
+
-------------------------------
93
+
94
+
The :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MigratingSessionHandler`
95
+
can be used to migrate between old and new save handlers without losing session data.
96
+
97
+
It can be used to support the following workflow:
98
+
99
+
* Switch to the migrating handler, with your new handler as the write-only one. The old handler behaves as usual and sessions get written to the new one.
100
+
* After your session gc period, verify the data in the new handler
101
+
* Update the migrating handler to use the old handler as the write-only one, so the sessions will now be read from the new handler. This step allows easier rollbacks.
102
+
* After verifying everything, switch from the migrating handler to the new handler
103
+
104
+
Example usage::
105
+
106
+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MigratingSessionHandler;
107
+
108
+
$oldSessionStorage = ...;
109
+
$newSessionStorage = ...;
110
+
111
+
// First step, for the the garbage collection period so we get all sessions in the new storage handler
112
+
$sessionStorage = new MigratingSessionHandler($oldSessionStorage, $newSessionStorage);
113
+
114
+
// Second step, just while we verify that the new session storage handler works as expected
115
+
$sessionStorage = new MigratingSessionHandler($newSessionStorage, $oldSessionStorage);
116
+
117
+
// Final step - switching to the new storage handler!
0 commit comments