Skip to content

Commit a3d5c6c

Browse files
committed
Merge pull request symfony#3342 from drak/session_c
Clarify settings for native file storage
2 parents 16fc80b + 13a3c66 commit a3d5c6c

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

cookbook/session/sessions_directory.rst

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
.. index::
22
single: Sessions, sessions directory
33

4-
Configuring the Directory where Sessions Files are Saved
4+
Configuring the Directory Where Sessions Files are Saved
55
========================================================
66

7-
By default, Symfony stores the session data in the cache directory. This
8-
means that when you clear the cache, any current sessions will also be
9-
deleted.
7+
By default, Symfony stores the session data in files in the cache
8+
directory ``%kernel.cach_dir%/sessions``. This means that when you clear
9+
the cache, any current sessions will also be deleted.
10+
11+
.. note::
12+
13+
If the ``session`` configuration key is set to ``~``, Symfony will use the
14+
global PHP ini values for ``session.save_handler``and associated
15+
``session.save_path`` from ``php.ini``.
16+
17+
.. note::
18+
19+
While the Symfony Full Stack Framework defaults to using the
20+
``session.handler.native_file``, the Symfony Standard Edition is
21+
configured to use PHP's global session settings by default and therefor
22+
sessions will be stored according to the `session.save_path` location
23+
and will not be deleted when clearing the cache.
1024

1125
Using a different directory to save session data is one method to ensure
1226
that your current sessions aren't lost when you clear Symfony's cache.
@@ -30,18 +44,24 @@ session directory to ``app/sessions``:
3044
# app/config/config.yml
3145
framework:
3246
session:
47+
handler_id: session.handler.native_file
3348
save_path: "%kernel.root_dir%/sessions"
3449
3550
.. code-block:: xml
3651
3752
<!-- app/config/config.xml -->
3853
<framework:config>
54+
<framework:session handler-id="session.handler.native_file" />
3955
<framework:session save-path="%kernel.root_dir%/sessions" />
4056
</framework:config>
4157
4258
.. code-block:: php
4359
4460
// app/config/config.php
4561
$container->loadFromExtension('framework', array(
46-
'session' => array('save-path' => "%kernel.root_dir%/sessions"),
62+
'session' => array(
63+
'handler-id' => 'session.handler.native_file',
64+
'save-path' => '%kernel.root_dir%/sessions',
65+
),
4766
));
67+

0 commit comments

Comments
 (0)