Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
755c201c
Commit
755c201c
authored
Mar 11, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweaked doc
parent
75c5efd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
doc/cookbook/session_storage.rst
doc/cookbook/session_storage.rst
+15
-10
No files found.
doc/cookbook/session_storage.rst
View file @
755c201c
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>`
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment