diff --git a/CookieAuth.php b/CookieAuth.php
index fedc88fcd57df18ef0188313e4e69ea90bd01cd8..aa1f875afd23f640402bfc0eeb89972d0a8df271 100644
--- a/CookieAuth.php
+++ b/CookieAuth.php
@@ -98,6 +98,7 @@ final class CookieAuth extends StudIPPlugin implements SystemPlugin
     public function login_action(): void
     {
         $redirect = Request::get('return_to', 'index.php');
+        $location = URLHelper::getURL($redirect);
 
         if (
             $this->cookie_login_user
@@ -109,7 +110,8 @@ final class CookieAuth extends StudIPPlugin implements SystemPlugin
             auth()->setAuthenticatedUser($this->cookie_login_user);
         }
 
-        header('Location: ' . URLHelper::getURL($redirect));
+        header('Location: ' . $location, true, 302);
+        die;
     }
 
     public static function onEnable($plugin_id)