function doLoginRedirect(LoginSession $session, $page) { while (@ob_end_clean()) { } header("Location: " . getLoginRedirect($session, $page)); exit; }
<?php require_once "common.php"; $username = @$_POST['username']; $password = @$_POST['password']; $page = @$_POST['page']; try { $session = $db->createLoginSession($username, $password); session_id($session->sessionId); if (!@session_start()) { throw new Exception("Unable to create new session"); } $rv = (object) ["redirect" => getLoginRedirect($session, $page)]; } catch (Exception $ex) { $rv = (object) ["error" => $ex->getMessage()]; } header("Content-Type: application/json"); echo json_encode($rv);