How to log users off automatically after a period of inactivity?

后端 未结 9 1839
心在旅途
心在旅途 2020-11-27 03:21

After a lot of search in the web and find nothing, I wonder if there is an easy way to automatic logout the user logged through the Symfony Security after an inactive period

9条回答
  •  难免孤独
    2020-11-27 03:46

    Works perfect with FOSUserbundle, thank you.

    I added this to the inner condition to prevent the anonymous user to get logged out.

    ...
    
    $isFullyAuthenticated = $this->securityContext->isGranted('IS_AUTHENTICATED_FULLY');
    
    if ($lapse > $this->maxIdleTime && $isFullyAuthenticated == true) {
    
     ... do logout / redirect etc.
    
    }
    

提交回复
热议问题