From c460879451e6f46f5cb1fc1e2d4e8d16c150f54a Mon Sep 17 00:00:00 2001 From: Raghav <raghavsmart1213@gmail.com> Date: Fri, 7 Mar 2025 08:21:31 +0000 Subject: [PATCH] Session intro --- sg.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sg.php diff --git a/sg.php b/sg.php new file mode 100644 index 0000000..7ae74b6 --- /dev/null +++ b/sg.php @@ -0,0 +1,28 @@ +<pre> +<?php + +// To use session include this function +session_start(); + +print("_SESSION\n"); +print_r($_SESSION); + + +// To Clear the values in session array but not delete. +if (isset($_GET['clear'])) { + printf("Clearing....\n"); + session_unset(); +} +/* +* We can assignment $_SESSION['A']; +* In string we can use without single quotes. +* print("a = $_SESSION[A]"); + +*/ +if (isset($_SESSION['a'])) { + printf("Exsiting value a = $_SESSION[a]\n"); +} else { + $_SESSION['a'] = time(); + printf("Assigning value to a = $_SESSION[a]\n"); +}?> +</pre> \ No newline at end of file -- GitLab