I'm building an Ajax app in Symfony2 where a user logs in, and then from that point forward everything is handled by POST requests. After defining the session lifetime to 5 minutes in config.yml
, I run into the problem of the user's session being invalidated after 5 minutes even though they're making POST requests. Each time a request is made, I'd like to reset the countdown before the session invalidates, but I'm not sure how to do this efficiently.
The method I'm currently thinking about is writing a listener for the kernel.request
event, checking if the request method is POST, and manipulating the session class. I haven't done this yet, but it doesn't seem like a clean solution, since the listener needs to fire everytime a request is made.
Here's my session config:
session:
default_locale: %locale%
auto_start: true
lifetime: 300
Any ideas? Is the solution plain PHP and not Symfony?