Nico Cnd
Nico Cnd

Reputation: 59

Symfony2 session timeout

I have a symfony2 project with a page to write the report of a meeting. It means the user can stay on this page and type for 2 hours without loading any new page. So when the user sends the form, his session has expired and he is sent to the login page. And he loses everything he typed.

I've already seen this post "symfony2 session lifetime" so here is my config.yml :

framework:
    session:
        handler_id:  ~
        cookie_lifetime: 86400
        gc_maxlifetime: 108000

So a 24 hours cookie lifetime and a 30 hour garbage collector... Still, I tried staying 1 hour on the page and I am disconnected...

Any idea where to look at ? Thanks !

Upvotes: 1

Views: 1279

Answers (2)

Reformat Code
Reformat Code

Reputation: 307

Try these settings:

framework:
    session:
            cookie_lifetime: 60 #60 seconds
            gc_maxlifetime: 50 #50 seconds - only needed for testing. Dont use this in a production environment
            gc_probability: 1 #only needed for testing. Dont use this in a production environment
            gc_divisor: 1 #only needed for testing. Dont use this in a production environment

You can see them over here: https://codedump.io/share/9eVPS5otSIuk

Upvotes: 0

Nico Cnd
Nico Cnd

Reputation: 59

So, it looks like changing symfony's config.yml doesn't work. But after modifying the gc_maxlifetime to 108000 in my php.ini it works, I am not disconnected after some idle time.

I guess this might be linked to the handler_id: ~ (which is default), but I don't really know why... Anyway, works this way :)

Upvotes: 1

Related Questions