File: D:/HostingSpaces/SBogers10/tops.komma.pro/wwwroot/lib/general/session.class.php
<?php
/**
* session.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 3/20/13
*/
class Session
{
public static function init()
{
// Start the session
session_start();
// Create some default sessions
Session::set('ip',$_SERVER['REMOTE_ADDR']);
}
/*
* Set function
*/
public static function set($key,$value)
{
if(is_array($key))
{
// Check if the session is two dimensional
$_SESSION[$key[0]][$key[1]] = $value;
}
else
{
$_SESSION[$key] = $value;
}
}
/*
* Get values from the session
*/
public static function get($key)
{
if(is_array($key))
{
// Check if the session is two dimensional
if(isset($_SESSION[$key[0]][$key[1]]))
{
return $_SESSION[$key[0]][$key[1]];
}
}
else if(isset($_SESSION[$key]))
{
return $_SESSION[$key];
}
return false;
}
/*
* Destroy a session
*/
public static function destroy($key=null)
{
if($key == null)
{
session_destroy();
}
else if(is_array($key))
{
// Check if the session is two dimensional
if(isset($_SESSION[$key[0]][$key[1]]))
{
unset($_SESSION[$key[0]][$key[1]]);
}
}
else
{
unset($_SESSION[$key]);
}
}
}