Commit 755c201c authored by Fabien Potencier's avatar Fabien Potencier

tweaked doc

parent 75c5efd8
How to use PdoSessionStorage to store sessions in the database How to use PdoSessionStorage to store sessions in the database
============================================================== ==============================================================
By default, the :doc:`SessionServiceProvider <providers/session>` writes session By default, the :doc:`SessionServiceProvider <providers/session>` writes
information in files with the NativeFileSessionStorage of Symfony2. Most medium session information in files using Symfony2 NativeFileSessionStorage. Most
to large websites use a database to store the session values instead of files, medium to large websites use a database to store sessions instead of files,
because databases are easier to use and scale in a multi-webserver environment. because databases are easier to use and scale in a multi-webserver
environment.
Symfony2 has multiple session storage solutions. For database, its called
`PdoSessionStorage <http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Storage/PdoSessionStorage.html> Symfony2 has multiple session storage solutions and one of them uses PDO to
To use it, you need to replace the ``session.storage`` service in your application. store sessions, `PdoSessionStorage
<http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Storage/PdoSessionStorage.html>
To use it, replace the ``session.storage`` service in your application like
explained below.
Example Example
------- -------
::
use Symfony\Component\HttpFoundation\Session\Storage\PdoSessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\PdoSessionStorage;
$app->register(new Silex\Provider\SessionServiceProvider()); $app->register(new Silex\Provider\SessionServiceProvider());
...@@ -44,7 +49,6 @@ Example ...@@ -44,7 +49,6 @@ Example
); );
}); });
Database structure Database structure
------------------ ------------------
...@@ -54,5 +58,6 @@ PdoSessionStorage needs a database table with 3 columns: ...@@ -54,5 +58,6 @@ PdoSessionStorage needs a database table with 3 columns:
* ``session_value``: Value column (TEXT or CLOB) * ``session_value``: Value column (TEXT or CLOB)
* ``session_time``: Time column (INTEGER) * ``session_time``: Time column (INTEGER)
Examples of SQL statements to create the session table on `Symfony2 cookbook You can find examples of SQL statements to create the session table in the
`Symfony2 cookbook
<http://symfony.com/doc/current/cookbook/configuration/pdo_session_storage.html>` <http://symfony.com/doc/current/cookbook/configuration/pdo_session_storage.html>`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment