@@ -7,7 +7,7 @@ How to Use PdoSessionHandler to Store Sessions in the Database
77The default Symfony session storage writes the session information to files.
88Most medium to large websites use a database to store the session values
99instead of files, because databases are easier to use and scale in a
10- multi webserver  environment.
10+ multiple web server  environment.
1111
1212Symfony has a built-in solution for database session storage called
1313:class: `Symfony\\ Component\\ HttpFoundation\\ Session\\ Storage\\ Handler\\ PdoSessionHandler `.
@@ -172,15 +172,18 @@ of your project's data, you can use the connection settings from the
172172 '%database_password%', 
173173 )); 
174174
175- 
176- ---------------------- 
175+ example-sql-statements :
176+ 
177+ Preparing the Database to Store Sessions
178+ ---------------------------------------- 
179+ 
180+ Before storing sessions in the database, you must create the table that stores
181+ the information. The following sections contain some examples of the SQL statements
182+ you may use for your specific database engine.
177183
178184MySQL
179185~~~~~ 
180186
181- The SQL statement for creating the needed database table might look like the
182- following (MySQL):
183- 
184187.. code-block :: sql 
185188
186189 CREATE TABLE `session` ( 
@@ -193,8 +196,6 @@ following (MySQL):
193196
194197~~~~~~~~~~ 
195198
196- For PostgreSQL, the statement should look like this:
197- 
198199.. code-block :: sql 
199200
200201 CREATE TABLE session ( 
@@ -207,8 +208,6 @@ For PostgreSQL, the statement should look like this:
207208
208209~~~~~~~~~~~~~~~~~~~~ 
209210
210- For MSSQL, the statement might look like the following:
211- 
212211.. code-block :: sql 
213212
214213 CREATE TABLE [dbo].[session]( 
@@ -225,3 +224,16 @@ For MSSQL, the statement might look like the following:
225224 ALLOW_PAGE_LOCKS = ON 
226225 ) ON [PRIMARY] 
227226 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] 
227+ 
228+ note ::
229+ 
230+  If the session data doesn't fit in the data column, it might get truncated
231+  by the database engine. To make matters worse, when the session data gets
232+  corrupted, PHP ignores the data without giving a warning.
233+ 
234+  If the application stores large amounts of session data, this problem can
235+  be solved by increasing the column size (use ``BLOB `` or even ``MEDIUMBLOB ``).
236+  When using MySQL as the database engine, you can also enable the `strict SQL mode `_
237+  to get noticed when such an error happens.
238+ 
239+ .. _`strict SQL mode` : https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html 
0 commit comments