8000 Adding MigratingSessionHandler docs by rossmotley · Pull Request #9496 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Adding MigratingSessionHandler docs #9496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions components/http_foundation/session_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ easily serve as examples if you wish to write your own.

* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler`
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MemcachedSessionHandler`
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MigratingSessionHandler`
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\RedisSessionHandler`
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MongoDbSessionHandler`
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NullSessionHandler`
Expand All @@ -87,6 +88,32 @@ Example usage::
$sessionStorage = new NativeSessionStorage(array(), new PdoSessionHandler($pdo));
$session = new Session($sessionStorage);

Migrating Between Save Handlers
-------------------------------

.. versionadded:: 4.1
  The ``MigratingSessionHandler`` class was introduced in Symfony 4.1.

If your application changes the way sessions are stored, use the
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MigratingSessionHandler`
to migrate between old and new save handlers without losing session data.

This is the recommended migration workflow:

#. 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::

$sessionStorage = new MigratingSessionHandler($oldSessionStorage, $newSessionStorage);

#. After your session gc period, verify that the data in the new handler is correct.
#. 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::

$sessionStorage = new MigratingSessionHandler($newSessionStorage, $oldSessionStorage);

#. After verifying that the sessions in your application are working, switch
from the migrating handler to the new handler.

Configuring PHP Sessions
~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
0