connect(); $auth = new Auth($db); $tempObject = new stdClass(); $auth->email = $data->email; $auth->password = $data->password; $status = $auth->login(); $tempObject->status = $status; if ($status == 200) { $tempObject->data = array( "isLoggedIn" => true, "role" => $auth->role, "name" => $auth->name ); $expiry = time() + (86400 * 30); setcookie("sid", $auth->sid, $expiry, "/"); setcookie("uid", $auth->uid, $expiry, "/"); } echo json_encode($tempObject);