in my web site, I implemented user authentification based on the documentation. What I want to know is how to disconnect automatically the user after 15 minutes of inactivity. Thanks in advance
you can set the session timeout to establish a function like this. see How to set expiration time to session in the controller? this will end the user's session with his first click after 15min of inactivity and redirect him to the login page.
an automated disconnect by eg redirecting to the logout url after 15min of inactivity (by javascript) is also possible.
As mentioned here the following snippet should take you to your goal:
$session->start();
if (time() - $session->getMetadataBag()->getCreated() > $maxTime) {
$session->invalidate();
throw new SessionExpired(); // redirect to expired session page
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.