Reputation: 2495
I am trying to force a time out after a certain number of seconds however even though the logout works, I am trying to implement a auto redirect to a URL which I am unable to implement. Any ideas?
I am following the example given on (the answer with the most votes): How to log users off automatically after a period of inactivity?
Upvotes: 3
Views: 4298
Reputation: 9362
That guide will only log you out after you make another request to the server. Meaning the page you are on currently could remain open forever.
It would be pretty easy to force a request to the server after a given time. In your template you can add a meta refresh:
<meta http-equiv="refresh" content="300">
Putting this in your header section of your html will reload the page after 5 minutes. The number is in seconds.
And then in the SessionIdleHandler
class you would just change the response to redirect where you wanted.
from:
$event->setResponse(new RedirectResponse($this->router->generate('fos_user_security_login')));
to:
$event->setResponse(new RedirectResponse($this->router->generate('my_bundle.my_route')));
Upvotes: 4