diff --git a/lib/middleware/AuthenticationMiddleware.php b/lib/middleware/AuthenticationMiddleware.php
index f86b06730f0475d82e53927fa25b026735a7b6a0..10de00401bd059798680b73547958b362c50a48d 100644
--- a/lib/middleware/AuthenticationMiddleware.php
+++ b/lib/middleware/AuthenticationMiddleware.php
@@ -34,6 +34,8 @@ final class AuthenticationMiddleware implements MiddlewareInterface
         } else {
             if (!match_route('dispatch.php/start')) {
                 $_SESSION['redirect_after_login'] = \Request::url();
+            } else {
+                unset($_SESSION['redirect_after_login']);
             }
             $response = $this->response_factory->createResponse(302);
             return $response->withHeader('Location', \URLHelper::getURL('dispatch.php/login'));