Reputation: 1839
I'm trying to make a "remember me" check button to fix the user session for more time than the lifetime specified in the config. I'm using the symfony2 session lifetime withe the help of the NativeSessionStorage
class.
$nativeSession = new NativeSessionStorage(
array(
'cookie_lifetime' => 3600*24*7
)
);
When i try to start the session that i've created, symfony throw this exception.
if($_SESSION){
session_destroy();
$nativeSession->start();
}
Anyone has the right process the declare this kind of sessions.
Upvotes: 1
Views: 1083
Reputation: 4766
If you want to build a remember me functionality in Symfony2, you can define a longer lifetime for this function in the symfony2 config. See the documentation for additional information. Example also taken from there.
# app/config/security.yml
security:
# ...
firewalls:
main:
# ...
remember_me:
secret: '%secret%'
lifetime: 604800 # 1 week in seconds
path: /
# by default, the feature is enabled by checking a
# checkbox in the login form (see below), uncomment the
# following line to always enable it.
#always_remember_me: true
Upvotes: 3