44Configuring 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
1125Using a different directory to save session data is one method to ensure
1226that 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