use("/", function (array $req, Response $res) { if(isset($_COOKIE["TOKEN"])){ // user mit token finden und im req übergeben $user = new User(""); } }); $app->get("/", function (array $req, Response $res) { $res->send("Hello World"); }); $app->get("/user", function (array $req, Response $res) { $res->send("user"); }); $app->get("/user/:id", function (array $req, Response $res) use ($db) { $db->select("utente", ["username" => $req["id"]]); $res->send("user " . $req["params"]["id"]); }); $app->post("/createuser", function (array $req, Response $res) use ($db) { $db->insert("utente", ["email" => "test@email.com", "parolaDordine" => "password", "nomeUtente" => "testuser"]); $res->send("user "); }); $app->post("/login", function( array $req, Response $res) use ($db) { $username = $req["body"]["username"]; $password = $req["body"]["password"]; $user = $db->select("utente", ["nomeUtente" => $username]); var_dump($user); return; $user = new User(); $user->loginWithUsername($username, $password); return; if(isset($user)){ setcookie($user->token, "TOKEN"); $res->send("Login successful", 200); }else{ $res->send("Login failed", 403); } }); $app->start();