From 73de1024a25a328fe3e78bfdf2d55f2106c213fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Wed, 15 Mar 2023 14:52:33 +0100 Subject: [PATCH] added login and logout --- login.php | 8 +++++++- logout.php | 27 +++++++++++++++++++++++++++ start.php | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 logout.php create mode 100644 start.php diff --git a/login.php b/login.php index 51ef051..c55cac2 100644 --- a/login.php +++ b/login.php @@ -23,12 +23,14 @@ } //$2y$10$yJMyDzprPAyf3rBnClqQ3O3poVb5w8gg2KcmZ10DVbTWSzgXeU.Ju //65de59ea345a79fb01174fb34a930d95 + session_start(); include 'db_connection.php'; $conn = openCon(); mysqli_set_charset($conn, "utf8"); $data = json_decode(file_get_contents("php://input"),true); + $email = $data["email"]; //"example@email.email"; $pass = $data["pass"]; //"hasło135$"; @@ -46,8 +48,12 @@ else return false; }; if(isset($answ["salt"]) && checkPassword($pass, $answ["salt"], $answ["hash"])){ + $_SESSION["email"] = $email; echo json_encode(true); } - else echo json_encode(false); + else { + $_SESSION["email"] = null; + echo json_encode(false); + } closeCon($conn); ?> \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..3faad83 --- /dev/null +++ b/logout.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/start.php b/start.php new file mode 100644 index 0000000..2a48e1d --- /dev/null +++ b/start.php @@ -0,0 +1,28 @@ + \ No newline at end of file