Wallogit.com
2017 © Pedro Peláez
Adds a session expiry listener
Adds a listener that expires user sessions after a configurable period of inactivity., (*1)
Add this require reference to your composer.json:, (*2)
php composer.phar require tui/session-bundle:~1.1
Add the Bundle to your app/AppKernel.php:, (*3)
public function registerBundles()
{
$bundles = array(
// …
new Tui/SessionBundle/TuiSessionBundle(),
}
// …
You can configure the timeout in your app.yml file:, (*4)
tui_session:
session_timeout: 3600 # One hour
By default when the session expires, the listener will invalidate the session and throw a CredentialsExpired exception. Obviously it'd be much better to redirect the user to a "Login expired" page. There are two ways you can do that:, (*5)
The listener can redirect to a given route when the session expires. This is super easy, but not very flexible. In your app.yml file:, (*6)
tui_session:
redirect_route: login_expired
Alternatively you can create a custom response, register it as a service and configure it to be returned instead. Here's a trivial example that uses the built-in response class., (*7)
tui_session:
expired_response: session_expired
services:
session_expired:
class: Symfony\Component\HttpFoundation\Response
arguments:
- 'Your login expired, sorry!'