Skip to content

[HttpFoundation] save session data as binary & add lazy-connect & create table & lifetime per session #10991

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions UPGRADE-2.5.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
UPGRADE FROM 2.4 to 2.5
=======================

HttpFoundation
--------------

* The PdoSessionHandler to store sessions in a database changed significantly.
- It now implements session locking to prevent loss of data by concurrent access to the same session.
- It does so using a transaction between opening and closing a session. For this reason, it's not recommended to
use the same database connection that you also use for your application logic. Otherwise you have to make sure
to access your database after the session is closed and committed. Instead of passing an existing connection
to the handler, you can now also pass a DSN string which will be used to lazy-connect when a session is started.
- Since accessing a session now blocks when the same session is still open, it is best practice to save the session
as soon as you don't need to write to it anymore. For example, read-only AJAX request to a session can save the
session immediately after opening it to increase concurrency.
- The expected schema of the table changed.
- Session data is binary text that can contain null bytes and thus should also be saved as-is in a binary column like BLOB.
For this reason, the handler does not base64_encode the data anymore.
- A new column to store the lifetime of a session is required. This allows to have different lifetimes per session
configured via session.gc_maxlifetime ini setting.
- You would need to migrate the table manually if you want to keep session information of your users.
- You could use PdoSessionHandler::createTable to initialize a correctly defined table depending on the used database vendor.

Routing
-------

Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/HttpFoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ CHANGELOG
2.5.0
-----

* PdoSessionHandler changes
- implemented session locking to prevent loss of data by concurrent access to the same session
- save session data in a binary column without base64_encode
- added lifetime column to the session table which allows to have different lifetimes for each session
- implemented lazy connections that are only opened when a session is used by either passing a dsn string explicitly
or falling back to session.save_path ini setting
- added a createTable method that initializes a correctly defined table depending on the database vendor
* added `JsonResponse::setEncodingOptions()` & `JsonResponse::getEncodingOptions()` for easier manipulation
of the options used while encoding data to JSON format.

Expand Down
Loading