Skip to content

Document host parameter and external parameters in "How to Use PdoSessionHandler..." #9493

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
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: 13 additions & 7 deletions doctrine/pdo_session_storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To use it, first register a new handler service:

Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
arguments:
- 'mysql:dbname=mydatabase'
- 'mysql:dbname=mydatabase, host=myhost'
- { db_username: myuser, db_password: mypassword }

# If you're using Doctrine & want to re-use that connection, then:
Expand All @@ -43,7 +43,7 @@ To use it, first register a new handler service:

<services>
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" public="false">
<argument>mysql:dbname=mydatabase</argument>
<argument>mysql:dbname=mydatabase, host=myhost</argument>
<argument type="collection">
<argument key="db_username">myuser</argument>
<argument key="db_password">mypassword</argument>
Expand All @@ -59,11 +59,17 @@ To use it, first register a new handler service:

$storageDefinition = $container->autowire(PdoSessionHandler::class)
->setArguments(array(
'mysql:dbname=mydatabase',
'mysql:dbname=mydatabase, host=myhost',
array('db_username' => 'myuser', 'db_password' => 'mypassword')
))
;

.. tip::

Configure the database credentials as
:doc:`parameters defined with environment variables </configuration/external_parameters>`
to make your application more secure.

Next, tell Symfony to use your service as the session handler:

.. configuration-block::
Expand Down Expand Up @@ -115,8 +121,8 @@ a second array argument to ``PdoSessionHandler``:

Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
arguments:
- 'mysql:dbname=mydatabase'
- { db_table: sessions, db_username: myuser, db_password: mypassword }
- 'mysql:dbname=mydatabase, host=myhost'
- { db_table: 'sessions', db_username: 'myuser', db_password: 'mypassword' }

.. code-block:: xml

Expand All @@ -129,7 +135,7 @@ a second array argument to ``PdoSessionHandler``:

<services>
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" public="false">
<argument>mysql:dbname=mydatabase</argument>
<argument>mysql:dbname=mydatabase, host=myhost</argument>
<argument type="collection">
<argument key="db_table">sessions</argument>
<argument key="db_username">myuser</argument>
Expand All @@ -148,7 +154,7 @@ a second array argument to ``PdoSessionHandler``:

$container->autowire(PdoSessionHandler::class)
->setArguments(array(
'mysql:dbname=mydatabase',
'mysql:dbname=mydatabase, host=myhost',
array('db_table' => 'sessions', 'db_username' => 'myuser', 'db_password' => 'mypassword')
))
;
Expand Down