Fix handling for session parameters

This commit is contained in:
Vladimir Khramtsov 2019-08-19 09:45:21 +03:00
parent aa53a71e03
commit b8c9e40980
5 changed files with 8 additions and 2 deletions

View File

@ -874,7 +874,7 @@ class FrameworkExtension extends Extension
// session storage
$container->setAlias('session.storage', $config['storage_id'])->setPrivate(true);
$options = ['cache_limiter' => '0'];
foreach (['name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'cookie_samesite', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor'] as $key) {
foreach (['name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'cookie_samesite', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'sid_length', 'sid_bits_per_character'] as $key) {
if (isset($config[$key])) {
$options[$key] = $config[$key];
}

View File

@ -37,6 +37,8 @@ $container->loadFromExtension('framework', [
'gc_maxlifetime' => 90000,
'gc_divisor' => 108,
'gc_probability' => 1,
'sid_length' => 22,
'sid_bits_per_character' => 4,
'save_path' => '/path/to/sessions',
],
'assets' => [

View File

@ -15,7 +15,7 @@
<framework:ssi enabled="true" />
<framework:profiler only-exceptions="true" enabled="false" />
<framework:router resource="%kernel.project_dir%/config/routing.xml" type="xml" />
<framework:session 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="false" use-cookies="true" save-path="/path/to/sessions" />
<framework:session 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="false" use-cookies="true" save-path="/path/to/sessions" sid-length="22" sid-bits-per-character="4" />
<framework:request>
<framework:format name="csv">
<framework:mime-type>text/csv</framework:mime-type>

View File

@ -29,6 +29,8 @@ framework:
gc_probability: 1
gc_divisor: 108
gc_maxlifetime: 90000
sid_length: 22
sid_bits_per_character: 4
save_path: /path/to/sessions
assets:
version: v1

View File

@ -530,6 +530,8 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals(108, $options['gc_divisor']);
$this->assertEquals(1, $options['gc_probability']);
$this->assertEquals(90000, $options['gc_maxlifetime']);
$this->assertEquals(22, $options['sid_length']);
$this->assertEquals(4, $options['sid_bits_per_character']);
$this->assertEquals('/path/to/sessions', $container->getParameter('session.save_path'));
}