According to the documentation, you can control the normal session lifetime through config.yml:
framework: session: cookie_lifetime: 3600
To set the service life per year: 3600 * 24 * 365 = 86400 * 365 = 31536000. Easy :).
This sets the session cookie lifetime to 1 hour. There are many other things you can customize, but why did I include a link to the documentation.
If you insist on doing it manually, in a specific case / controller, pass an array of parameters to the controller. Perhaps this will work instead of using the setOptions method: if your php.ini contains:
session.auto_start = 1
Then instantiating the NativeSessionStorage will automatically and immediately create a session with a default lifetime. After that, the setting will be insignificant or no difference. Check ini settings or follow these steps:
$test = new NativeSessionStorage(); var_dump($test->isStarted())
If it unloads true , try:
$lifetime = new NativeSessionStorage( array( 'cookie_lifetime' => 31536000 ) );
Symfony2 sessions can be found here .
If you are using Symfony2.4, there is a special section in the documents on catchy features , as Jakub Polak noted. Its essence is that the flag should be called by _remember_me , that config.yml should determine the value of %secret% , and that you add a (customized) version of this file to the security.yml file:
firewalls: main: remember_me: key: "%secret%" lifetime: 31536000 path: / domain: ~
But the documentation explains all of this, but you have to turn the manual around a bit. For example, if you want to specify different mem-me behavior for certain sections, change main in the yml snippet above and add the pattern parameter as here .
It is probably best to scan the entire security section .