From 177ec227eb2d928b486fd3baf2795328e33f8743 Mon Sep 17 00:00:00 2001 From: Raghav <raghavsmart1213@gmail.com> Date: Mon, 17 Mar 2025 06:11:36 +0000 Subject: [PATCH] Included classes for session() in Sessiontest.php --- libs/load.php | 21 +++++++++++---------- sessiontest.php | 15 ++++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/libs/load.php b/libs/load.php index 27ead7a..cc91e43 100644 --- a/libs/load.php +++ b/libs/load.php @@ -4,6 +4,7 @@ include_once '_includes/Mic.class.php'; include_once '_includes/Database.class.php'; include_once '_includes/User.class.php'; +include_once '_includes/Session.class.php'; function load_template($name) { @@ -12,14 +13,14 @@ function load_template($name) } // Function to validate the credentials. -function validate_credentials($email, $password) -{ +// function validate_credentials($email, $password) +// { - // pass credential to class function - User::getCredential($email, $password); - if ($email == "raghav@gmail.com" and $password == "raghav") { - return true; - } else { - return false; - } -} +// // pass credential to class function +// User::getCredential($email, $password); +// if ($email == "raghav@gmail.com" and $password == "raghav") { +// return true; +// } else { +// return false; +// } +// } diff --git a/sessiontest.php b/sessiontest.php index 8d4a07c..3b4cee4 100644 --- a/sessiontest.php +++ b/sessiontest.php @@ -1,8 +1,9 @@ <pre> <?php +include 'libs/load.php'; // To use session include this function -session_start(); +Session::start(); print("_SESSION\n"); print_r($_SESSION); @@ -12,14 +13,14 @@ print("Session ID = " . session_id()."\n"); // To Clear the values in session array but not delete. if (isset($_GET['clear'])) { printf("Clearing....\n"); - session_unset(); + Session::unset_all(); print("Session ID[unset] = " . session_id()."\n"); } // To destroy the session if (isset($_GET['destroy'])) { printf("Destroying..\n"); - session_destroy(); + Session::destroy(); print("Session ID[destroyed] = " . session_id()."\n"); } /* @@ -28,10 +29,10 @@ if (isset($_GET['destroy'])) { * print("a = $_SESSION[A]"); */ -if (isset($_SESSION['a'])) { - printf("Exsiting value a = $_SESSION[a]\n"); +if (Session::isset('a')) { + printf("Exsiting value a = ". Session::get('a'). "\n"); } else { - $_SESSION['a'] = time(); - printf("Assigning value to a = $_SESSION[a]\n"); + Session::set('a', time()); + printf("Assigning value to a = ". Session::get('a'). "\n"); }?> </pre> \ No newline at end of file -- GitLab