Skip to content

Clarify settings #3281

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
wants to merge 1 commit into from
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
28 changes: 24 additions & 4 deletions cookbook/session/sessions_directory.rst
Original file line number Diff line number Diff line change
@@ -4,9 +4,23 @@
Configuring the Directory where Sessions Files are Saved
========================================================

By default, Symfony stores the session data in the cache directory. This
means that when you clear the cache, any current sessions will also be
deleted.
By default, Symfony stores the session data in files in the cache
directory `"%kernel.cach_dir%/sessions"`. This means that when you clear
the cache, any current sessions will also be deleted.

.. note::

If the ``session`` configuration key is set to ``~``, Symfony will use the
global PHP ini values for ``session.save_handler``and associated
``session.save_path`` from ``php.ini``.

.. note::

While the Symfony Full Stack Framework defaults to using the
``session.handler.native_file``, the Symfony Standard Edition is
configured to use PHP's global session settings by default and therefor
sessions will be stored according to the `session.save_path` location
and will not be deleted when clearing the cache.

Using a different directory to save session data is one method to ensure
that your current sessions aren't lost when you clear Symfony's cache.
@@ -30,18 +44,24 @@ session directory to ``app/sessions``:
# app/config/config.yml
framework:
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/sessions"
.. code-block:: xml
<!-- app/config/config.xml -->
<framework:config>
<framework:session handler-id="session.handler.native_file" />
<framework:session save-path="%kernel.root_dir%/sessions" />
</framework:config>
.. code-block:: php
// app/config/config.php
$container->loadFromExtension('framework', array(
'session' => array('save-path' => "%kernel.root_dir%/sessions"),
'session' => array(
'handler-id' => "session.handler.native_file"),
'save-path' => "%kernel.root_dir%/sessions"),
),
));