2015-03-08 18:02:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Session {
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
private static $started = false;
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
public static function start()
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2015-03-27 02:00:01 +01:00
|
|
|
if(self::$started)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
self::$started = session_start();
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
public static function started()
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2015-03-27 02:00:01 +01:00
|
|
|
return self::$started;
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
public static function destroy()
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2015-03-27 02:00:01 +01:00
|
|
|
session_destroy();
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
unset($_SESSION);
|
|
|
|
|
|
|
|
self::$started = false;
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
public static function set($key, $value)
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2015-03-27 02:00:01 +01:00
|
|
|
$key = 's_'.$key;
|
|
|
|
|
|
|
|
$_SESSION[$key] = $value;
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
public static function get($key)
|
2015-03-08 18:02:59 +01:00
|
|
|
{
|
2015-03-27 02:00:01 +01:00
|
|
|
$key = 's_'.$key;
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-03-27 02:00:01 +01:00
|
|
|
if( isset($_SESSION[$key]) )
|
|
|
|
return $_SESSION[$key];
|
2015-03-08 18:02:59 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|