|
1 | 1 | .. index::
|
2 | 2 | single: Sessions, sessions directory
|
3 | 3 |
|
4 |
| -Configuring Sessions Directory |
5 |
| -============================== |
| 4 | +Configuring the Directory where Sessions Files are Saved |
| 5 | +======================================================== |
6 | 6 |
|
7 | 7 | By default, Symfony stores the session data in the cache directory. This
|
8 | 8 | means that when you clear the cache, any current sessions will also be
|
9 | 9 | deleted.
|
10 | 10 |
|
11 |
| -Using a different directory to save session data is one method of retaining |
12 |
| -current sessions during a clearing of the cache. |
| 11 | +Using a different directory to save session data is one method to ensure |
| 12 | +that your current sessions aren't lost when you clear Symfony's cache. |
13 | 13 |
|
14 | 14 | .. tip::
|
15 | 15 |
|
16 | 16 | Using a different session save handler is an excellent (yet more complex)
|
17 | 17 | method of session management available within Symfony. See
|
18 |
| - :doc:`/components/http_foundation/session_configuration.rst` for a |
19 |
| - discussion of session save handlers. |
| 18 | + :doc:`/components/http_foundation/session_configuration` for a |
| 19 | + discussion of session save handlers. There is also an entry in the cookbook |
| 20 | + about storing sessions in the :doc:`database</cookbook/configuration/pdo_session_storage>`. |
20 | 21 |
|
21 | 22 | To change the directory in which Symfony saves session data, you only need
|
22 |
| -change the framework configuration. In this example, we are changing the |
23 |
| -session directory to 'app/sessions': |
| 23 | +change the framework configuration. In this example, you will change the |
| 24 | +session directory to ``app/sessions``: |
24 | 25 |
|
25 | 26 | .. configuration-block::
|
26 | 27 |
|
27 | 28 | .. code-block:: yaml
|
28 | 29 |
|
29 | 30 | # app/config/config.yml
|
30 |
| -
|
31 | 31 | framework:
|
32 | 32 | session:
|
33 |
| - save_path: %kernel.root_dir%/sessions |
| 33 | + save_path: "%kernel.root_dir%/sessions" |
34 | 34 |
|
35 | 35 | .. code-block:: xml
|
36 | 36 |
|
37 | 37 | <!-- app/config/config.xml -->
|
38 |
| -
|
39 | 38 | <framework:config>
|
40 | 39 | <framework:session save-path="%kernel.root_dir%/sessions" />
|
41 | 40 | </framework:config>
|
42 | 41 |
|
43 | 42 | .. code-block:: php
|
44 | 43 |
|
45 | 44 | // app/config/config.php
|
46 |
| -
|
47 | 45 | $container->loadFromExtension('framework', array(
|
48 | 46 | 'session' => array('save-path' => "%kernel.root_dir%/sessions"),
|
49 | 47 | ));
|
50 |
| -
|
0 commit comments