request->getCookie('token'); if ($token) { // If token exists, redirect to dashboard return redirect()->to('/dashboard'); } return view('pages/login', [ 'title' => 'Login', 'description' => 'Sign in to your CLQMS account' ]); } /** * Handle logout - clear cookie and redirect */ public function logout() { // Determine secure status matching Auth controller logic $isSecure = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'; // Manually expire the cookie with matching attributes to ensure deletion $this->response->setCookie([ 'name' => 'token', 'value' => '', 'expire' => time() - 3600, 'path' => '/', 'secure' => $isSecure, 'httponly' => true, 'samesite' => $isSecure ? 'None' : 'Lax' ]); return redirect()->to('/login')->withCookies(); } }