getAttribute('route'); $routeName = $route->getName(); $sessionService = new SessionService(); if ((!isset($_COOKIE['grocy_session']) || !$sessionService->IsValidSession($_COOKIE['grocy_session'])) && $routeName !== 'login') { $response = $response->withRedirect('/login'); } else { $response = $next($request, $response); } return $response; } }