From 20eeb81f7f056ec45de26022d9486f12f75a4a46 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:42:29 +0400 Subject: [PATCH] add logout feature --- src/controllers/Profile.php | 7 +++++++ src/views/Profile.php | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/controllers/Profile.php b/src/controllers/Profile.php index 70641f0..144c475 100644 --- a/src/controllers/Profile.php +++ b/src/controllers/Profile.php @@ -4,6 +4,7 @@ use Steamy\Core\Controller; use Steamy\Model\User; + class Profile { use Controller; @@ -16,6 +17,12 @@ public function index(): void redirect('login'); } + // log out user if logout button clicked + if (isset($_POST['logout_submit'])) { + $_SESSION = array(); + redirect('login'); + } + // fetch user details from database $current_user = new User(); diff --git a/src/views/Profile.php b/src/views/Profile.php index 5316131..9a50001 100644 --- a/src/views/Profile.php +++ b/src/views/Profile.php @@ -1,6 +1,6 @@

Your account

-

Personal details

+

Personal details

-

Your orders

+

Orders summary

@@ -79,7 +79,9 @@ - - + + + + \ No newline at end of file