Skip to content
Snippets Groups Projects
Commit 4a4896e2 authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

session

parent 8d08a4ac
No related branches found
No related tags found
No related merge requests found
<?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;
}
}
}
<?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.
......
sg.php 0 → 100644
<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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment