Skip to content

Commit 4a16c2a

Browse files
committed
Merge branch 'changing_session_directory' of git://github.com/kevintweber/symfony-docs into kevintweber-changing_session_directory
Conflicts: cookbook/session/index.rst
2 parents ba7ab6f + cae8707 commit 4a16c2a

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

cookbook/session/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Sessions
66

77
proxy_examples
88
locale_sticky_session
9+
sessions_directory
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. index::
2+
single: Sessions, sessions directory
3+
4+
Configuring Sessions Directory
5+
==============================
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.
10+
11+
Using a different directory to save session data is one method of retaining
12+
current sessions during a clearing of the cache.
13+
14+
.. tip::
15+
16+
Using a different session save handler is an excellent (yet more complex)
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.
20+
21+
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':
24+
25+
.. configuration-block::
26+
27+
.. code-block:: yaml
28+
29+
# app/config/config.yml
30+
31+
framework:
32+
session:
33+
save_path: %kernel.root_dir%/sessions
34+
35+
.. code-block:: xml
36+
37+
<!-- app/config/config.xml -->
38+
39+
<framework:config>
40+
<framework:session save-path="%kernel.root_dir%/sessions" />
41+
</framework:config>
42+
43+
.. code-block:: php
44+
45+
// app/config/config.php
46+
47+
$container->loadFromExtension('framework', array(
48+
'session' => array('save-path' => "%kernel.root_dir%/sessions"),
49+
));
50+

0 commit comments

Comments
 (0)