3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller
;
7 use Shaarli\Security\LoginManager
;
9 use Slim\Http\Response
;
12 * Class LogoutController
14 * Slim controller used to logout the user.
15 * It invalidates page cache and terminate the user session. Then it redirects to the homepage.
17 * @package Front\Controller
19 class LogoutController
extends ShaarliController
21 public function index(Request
$request, Response
$response): Response
23 $this->container
->pageCacheManager
->invalidateCaches();
24 $this->container
->sessionManager
->logout();
26 // TODO: switch to a simple Cookie manager allowing to check the session, and create mocks.
27 setcookie(LoginManager
::$STAY_SIGNED_IN_COOKIE, 'false', 0, $this->container
->webPath
);
29 return $response->withRedirect('./');