[FrameworkBundle] Allow configuration of session garbage collection for session 'keep-alive'.
This commit is contained in:
parent
69fc07a21c
commit
749593d1c3
@ -52,6 +52,12 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
|
|||||||
'httponly' are now prefixed with cookie_ when dumped to the container
|
'httponly' are now prefixed with cookie_ when dumped to the container
|
||||||
* Added `handler_id` configuration under `session` key to represent `session.handler`
|
* Added `handler_id` configuration under `session` key to represent `session.handler`
|
||||||
service, defaults to `session.handler.native_file`.
|
service, defaults to `session.handler.native_file`.
|
||||||
|
* Added `gc_maxlifetime` (default 86400 seconds), `gc_probability` (default 1),
|
||||||
|
and `gc_divisor` (default 100) to session configuration. This means session
|
||||||
|
garbage collection has 1/100 chance of being run. The `gc_maxlifetime` means
|
||||||
|
how long a session can idle for which is separate from cookie lifetime which
|
||||||
|
defines how long a cookie can be store on the remote client.
|
||||||
|
|
||||||
|
|
||||||
### MonologBundle
|
### MonologBundle
|
||||||
|
|
||||||
|
@ -175,6 +175,9 @@ class Configuration implements ConfigurationInterface
|
|||||||
->scalarNode('cookie_domain')->end()
|
->scalarNode('cookie_domain')->end()
|
||||||
->booleanNode('cookie_secure')->end()
|
->booleanNode('cookie_secure')->end()
|
||||||
->booleanNode('cookie_httponly')->end()
|
->booleanNode('cookie_httponly')->end()
|
||||||
|
->scalarNode('gc_divisor')->defaultValue(100)->end()
|
||||||
|
->scalarNode('gc_probability')->defaultValue(1)->end()
|
||||||
|
->scalarNode('gc_maxlifetime')->defaultValue(86400)->end()
|
||||||
->scalarNode('lifetime')->setInfo('DEPRECATED! Please use: cookie_lifetime')->end()
|
->scalarNode('lifetime')->setInfo('DEPRECATED! Please use: cookie_lifetime')->end()
|
||||||
->scalarNode('path')->setInfo('DEPRECATED! Please use: cookie_path')->end()
|
->scalarNode('path')->setInfo('DEPRECATED! Please use: cookie_path')->end()
|
||||||
->scalarNode('domain')->setInfo('DEPRECATED! Please use: cookie_domain')->end()
|
->scalarNode('domain')->setInfo('DEPRECATED! Please use: cookie_domain')->end()
|
||||||
|
@ -295,7 +295,7 @@ class FrameworkExtension extends Extension
|
|||||||
// session storage
|
// session storage
|
||||||
$container->setAlias('session.storage', $config['storage_id']);
|
$container->setAlias('session.storage', $config['storage_id']);
|
||||||
$options = array();
|
$options = array();
|
||||||
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'auto_start') as $key) {
|
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'auto_start', 'gc_maxlifetime', 'gc_probability', 'gc_divisor') as $key) {
|
||||||
if (isset($config[$key])) {
|
if (isset($config[$key])) {
|
||||||
$options[$key] = $config[$key];
|
$options[$key] = $config[$key];
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,9 @@
|
|||||||
<!-- end of deprecated attributes -->
|
<!-- end of deprecated attributes -->
|
||||||
<xsd:attribute name="cache-limiter" type="xsd:string" />
|
<xsd:attribute name="cache-limiter" type="xsd:string" />
|
||||||
<xsd:attribute name="auto-start" type="xsd:boolean" />
|
<xsd:attribute name="auto-start" type="xsd:boolean" />
|
||||||
|
<xsd:attribute name="gc-maxlifetime" type="xsd:integer" />
|
||||||
|
<xsd:attribute name="gc-divisor" type="xsd:integer" />
|
||||||
|
<xsd:attribute name="gc-probability" type="xsd:integer" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="templating">
|
<xsd:complexType name="templating">
|
||||||
|
@ -28,6 +28,9 @@ $container->loadFromExtension('framework', array(
|
|||||||
'domain' => 'example.com',
|
'domain' => 'example.com',
|
||||||
'secure' => true,
|
'secure' => true,
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
|
'gc_maxlifetime' => 90000,
|
||||||
|
'gc_divisor' => 108,
|
||||||
|
'gc_probability' => 1,
|
||||||
),
|
),
|
||||||
'templating' => array(
|
'templating' => array(
|
||||||
'assets_version' => 'SomeVersionScheme',
|
'assets_version' => 'SomeVersionScheme',
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<framework:esi enabled="true" />
|
<framework:esi enabled="true" />
|
||||||
<framework:profiler only-exceptions="true" />
|
<framework:profiler only-exceptions="true" />
|
||||||
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
||||||
<framework:session auto-start="true" 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" />
|
<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" />
|
||||||
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
||||||
<framework:loader>loader.foo</framework:loader>
|
<framework:loader>loader.foo</framework:loader>
|
||||||
<framework:loader>loader.bar</framework:loader>
|
<framework:loader>loader.bar</framework:loader>
|
||||||
|
@ -22,6 +22,9 @@ framework:
|
|||||||
domain: example.com
|
domain: example.com
|
||||||
secure: true
|
secure: true
|
||||||
httponly: true
|
httponly: true
|
||||||
|
gc_probability: 1
|
||||||
|
gc_divisor: 108
|
||||||
|
gc_maxlifetime: 90000
|
||||||
templating:
|
templating:
|
||||||
assets_version: SomeVersionScheme
|
assets_version: SomeVersionScheme
|
||||||
assets_base_urls: http://cdn.example.com
|
assets_base_urls: http://cdn.example.com
|
||||||
|
@ -88,6 +88,9 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertEquals('example.com', $options['cookie_domain']);
|
$this->assertEquals('example.com', $options['cookie_domain']);
|
||||||
$this->assertTrue($options['cookie_secure']);
|
$this->assertTrue($options['cookie_secure']);
|
||||||
$this->assertTrue($options['cookie_httponly']);
|
$this->assertTrue($options['cookie_httponly']);
|
||||||
|
$this->assertEquals(108, $options['gc_divisor']);
|
||||||
|
$this->assertEquals(1, $options['gc_probability']);
|
||||||
|
$this->assertEquals(90000, $options['gc_maxlifetime']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSessionDeprecatedMergeFull()
|
public function testSessionDeprecatedMergeFull()
|
||||||
|
Reference in New Issue
Block a user