8000 [FrameworkBundle] Make session save path configurable · kimhemsoe/symfony@c0e7ee9 · GitHub
[go: up one dir, main page]

Skip to content

Commit c0e7ee9

Browse files
committed
[FrameworkBundle] Make session save path configurable
1 parent 114bc14 commit c0e7ee9

File tree

8 files changed

+10
-2
lines changed

8 files changed

+10
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
181181
->scalarNode('gc_divisor')->end()
182182
->scalarNode('gc_probability')->end()
183183
->scalarNode('gc_maxlifetime')->end()
184+
->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
184185
->scalarNode('lifetime')->setInfo('DEPRECATED! Please use: cookie_lifetime')->end()
185186
->scalarNode('path')->setInfo('DEPRECATED! Please use: cookie_path')->end()
186187
->scalarNode('domain')->setInfo('DEPRECATED! Please use: cookie_domain')->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
313313
// session handler (the internal callback registered with PHP session management)
314314
$container->setAlias('session.handler', $config['handler_id']);
315315

316+
$container->setParameter('session.save_path', $config['save_path']);
317+
316318
$this->addClassesToCompile(array(
317319
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
318320
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface',

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
<xsd:attribute name="gc-maxlifetime" type="xsd:string" />
9090
<xsd:attribute name="gc-divisor" type="xsd:string" />
9191
<xsd:attribute name="gc-probability" type="xsd:string" />
92+
<xsd:attribute name="save-path" type="xsd:string" />
9293
</xsd:complexType>
9394

9495
<xsd:complexType name="templating">

src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</service>
3636

3737
<service id="session.handler.native_file" class="%session.handler.native_file.class%" public="false">
38-
<argument>%kernel.cache_dir%/sessions</argument>
38+
<argument>%session.save_path%</argument>
3939
</service>
4040

4141
<service id="session_listener" class="%session_listener.class%">

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'gc_maxlifetime' => 90000,
3232
'gc_divisor' => 108,
3333
'gc_probability' => 1,
34+
'save_path' => '/path/to/sessions',
3435
),
3536
'templating' => array(
3637
'assets_version' => 'SomeVersionScheme',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<framework:esi enabled="true" />
1313
<framework:profiler only-exceptions="true" />
1414
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
15-
<framework:session auto-start="true" gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
15+
<framework:session auto-start="true" gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" save-path="/path/to/sessions" />
1616
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
1717
<framework:loader>loader.foo</framework:loader>
1818
<framework:loader>loader.bar</framework:loader>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ framework:
2525
gc_probability: 1
2626
gc_divisor: 108
2727
gc_maxlifetime: 90000
28+
save_path: /path/to/sessions
2829
templating:
2930
assets_version: SomeVersionScheme
3031
assets_base_urls: http://cdn.example.com

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public function testSession()
9191
$this->assertEquals(108, $options['gc_divisor']);
9292
$this->assertEquals(1, $options['gc_probability']);
9393
$this->assertEquals(90000, $options['gc_maxlifetime']);
94+
95+
$this->assertEquals('/path/to/sessions', $container->getParameter('session.save_path'));
9496
}
9597

9698
public function testSessionDeprecatedMergeFull()

0 commit comments

Comments
 (0)
0