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
7df7761c
Commit
7df7761c
authored
Nov 09, 2012
by
ChrisRiddell
Committed by
Fabien Potencier
Nov 13, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Example for DoctrineServiceProvider in session cookbook
parent
404264bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
5 deletions
+32
-5
doc/cookbook/session_storage.rst
doc/cookbook/session_storage.rst
+32
-5
No files found.
doc/cookbook/session_storage.rst
View file @
7df7761c
...
@@ -15,8 +15,8 @@ has multiple storage handlers and one of them uses PDO to store sessions,
...
@@ -15,8 +15,8 @@ has multiple storage handlers and one of them uses PDO to store sessions,
To use it, replace the ``session.storage.handler`` service in your application
To use it, replace the ``session.storage.handler`` service in your application
like explained below.
like explained below.
Exampl
e
With a dedicated PDO servic
e
-------
-------
---------------------
.. code-block:: php
.. code-block:: php
...
@@ -28,7 +28,7 @@ Example
...
@@ -28,7 +28,7 @@ Example
$app['pdo.user'] = 'myuser';
$app['pdo.user'] = 'myuser';
$app['pdo.password'] = 'mypassword';
$app['pdo.password'] = 'mypassword';
$app['
pdo
.db_options'] = array(
$app['
session
.db_options'] = array(
'db_table' => 'session',
'db_table' => 'session',
'db_id_col' => 'session_id',
'db_id_col' => 'session_id',
'db_data_col' => 'session_value',
'db_data_col' => 'session_value',
...
@@ -46,7 +46,34 @@ Example
...
@@ -46,7 +46,34 @@ Example
$app['session.storage.handler'] = $app->share(function () use ($app) {
$app['session.storage.handler'] = $app->share(function () use ($app) {
return new PdoSessionHandler(
return new PdoSessionHandler(
$app['pdo'],
$app['pdo'],
$app['pdo.db_options'],
$app['session.db_options'],
$app['session.storage.options']
);
});
Using the DoctrineServiceProvider
---------------------------------
When using the :doc:`DoctrineServiceProvider </providers/doctrine>` You don't
have to make another database connection, simply pass the getWrappedConnection method.
.. code-block:: php
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
$app->register(new Silex\Provider\SessionServiceProvider());
$app['session.db_options'] = array(
'db_table' => 'session',
'db_id_col' => 'session_id',
'db_data_col' => 'session_value',
'db_time_col' => 'session_time',
);
$app['session.storage.handler'] = $app->share(function () use ($app) {
return new PdoSessionHandler(
$app['db']->getWrappedConnection(),
$app['session.db_options'],
$app['session.storage.options']
$app['session.storage.options']
);
);
});
});
...
@@ -62,4 +89,4 @@ PdoSessionStorage needs a database table with 3 columns:
...
@@ -62,4 +89,4 @@ PdoSessionStorage needs a database table with 3 columns:
You can find examples of SQL statements to create the session table in the
You can find examples of SQL statements to create the session table in the
`Symfony2 cookbook
`Symfony2 cookbook
<http://symfony.com/doc/current/cookbook/configuration/pdo_session_storage.html>`_
<http://symfony.com/doc/current/cookbook/configuration/pdo_session_storage.html
#example-sql-statements
>`_
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