1
1
.. index ::
2
2
single: Sessions, sessions directory
3
3
4
- Configuring the Directory where Sessions Files are Saved
4
+ Configuring the Directory Where Sessions Files are Saved
5
5
========================================================
6
6
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.
10
24
11
25
Using a different directory to save session data is one method to ensure
12
26
that your current sessions aren't lost when you clear Symfony's cache.
@@ -30,18 +44,24 @@ session directory to ``app/sessions``:
30
44
# app/config/config.yml
31
45
framework :
32
46
session :
47
+ handler_id : session.handler.native_file
33
48
save_path : " %kernel.root_dir%/sessions"
34
49
35
50
.. code-block :: xml
36
51
37
52
<!-- app/config/config.xml -->
38
53
<framework : config >
54
+ <framework : session handler-id =" session.handler.native_file" />
39
55
<framework : session save-path =" %kernel.root_dir%/sessions" />
40
56
</framework : config >
41
57
42
58
.. code-block :: php
43
59
44
60
// app/config/config.php
45
61
$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
+ ),
47
66
));
67
+
0 commit comments