8000 minor #9496 Adding MigratingSessionHandler docs (rossmotley, javiereg… · symfony/symfony-docs@8dd54bb · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 8dd54bb

Browse files
committed
minor #9496 Adding MigratingSessionHandler docs (rossmotley, javiereguiluz)
This PR was merged into the 4.1 branch. Discussion ---------- Adding MigratingSessionHandler docs Adding `MigratingSessionHandler` documentation for symfony/symfony#26096 Commits ------- e93756f Added the versionadded directive 386f639 Reworded and simplified 7c8264d Update session_configuration.rst e971074 Update session_configuration.rst 91aa58d Adding MigratingSessionHandler docs
2 parents 1ca0337 + e93756f commit 8dd54bb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

components/http_foundation/session_configuration.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
90117
Configuring PHP Sessions
91118
~~~~~~~~~~~~~~~~~~~~~~~~
92119

0 commit comments

Comments
 (0)
0