diff --git a/libs/includes/Session.class.php b/libs/includes/Session.class.php new file mode 100644 index 0000000000000000000000000000000000000000..8204808180b56d73b02ccb7c1cfa129037769939 --- /dev/null +++ b/libs/includes/Session.class.php @@ -0,0 +1,42 @@ +<?php + +class Session +{ + public static function start() + { + session_start(); + } + + public static function unset() + { + session_unset(); + } + public static function destroy() + { + session_destroy(); + } + + public static function set($key, $value) + { + $_SESSION[$key] = $value; + } + + public static function delete($key) + { + unset($_SESSION[$key]); + } + + public static function isset($key) + { + return isset($_SESSION[$key]); + } + + public static function get($key, $default=false) + { + if (Session::isset($key)) { + return $_SESSION[$key]; + } else { + return $default; + } + } +} diff --git a/libs/load.php b/libs/load.php index b532cd575f16e8ca0e6dab4a53681b28701cd9bc..7c322bf9e7cee96b78df548cc760ebc3d48ab02f 100644 --- a/libs/load.php +++ b/libs/load.php @@ -1,9 +1,11 @@ <?php - +include_once 'includes/Session.class.php'; include_once 'includes/Mic.class.php'; include_once 'includes/User.class.php'; include_once 'includes/Database.class.php'; +Session::start(); + function load_template($name) { include $_SERVER['DOCUMENT_ROOT']."/app/_templates/$name.php"; //not consistant. diff --git a/sg.php b/sg.php new file mode 100644 index 0000000000000000000000000000000000000000..75adc884cbbc26ceb7be11c2703bb505456c8b70 --- /dev/null +++ b/sg.php @@ -0,0 +1,31 @@ +<pre> +<?php +// setcookie("testcookie", "testvalue", time() + (86400 * 30), "/"); +include 'libs/load.php'; + +print("_SESSION \n"); +print_r($_SESSION); +print("_SERVER \n"); +print_r($_SERVER); + +if (isset($_GET['clear'])) { + printf("Clearing...\n"); + Session::unset(); +} + +if (Session::isset('a')) { + printf("A already exists... Value: ".Session::get('a')."\n"); +} else { + Session::set('a', time()); + printf("Assigning new value... Value: $_SESSION[a]\n"); +} + +if (isset($_GET['destroy'])) { + printf("Destroying...\n"); + Session::destroy(); +} + + + + +?></pre> \ No newline at end of file