From 6969e57230bf9c728117e15d28ebd89365e6fd32 Mon Sep 17 00:00:00 2001 From: Abhi200206 <120104020+Abhi200206@users.noreply.github.com> Date: Fri, 19 May 2023 15:59:33 +0530 Subject: [PATCH] cookie added in login.php --- .../Components/funwithscience_backend/login.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/funwithphysics/src/Components/funwithscience_backend/login.php b/funwithphysics/src/Components/funwithscience_backend/login.php index 527ecb1ed..0ad4e834b 100644 --- a/funwithphysics/src/Components/funwithscience_backend/login.php +++ b/funwithphysics/src/Components/funwithscience_backend/login.php @@ -49,4 +49,18 @@ }else { echo "0"; } +// Set the cookie when the user logs in +$expiration_time = time() + 86400; // 24 hours in seconds +setcookie('logout_cookie', 'true', $expiration_time); +// Check for the presence of the logout cookie +if (isset($_COOKIE['logout_cookie'])) { + // Perform logout actions here + // For example, destroy the session and redirect the user to the login page + session_start(); // Start the session if not already started + session_destroy(); // Destroy the session + // Redirect the user to the login page + header('Location: login.php'); + exit(); +} + ?>