1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00
movim_ynh/sources/system/Session.php
2016-03-29 14:12:33 +02:00

66 lines
1.3 KiB
PHP

<?php
class Session
{
protected static $instance;
protected static $sid = null;
protected $values = array();
/**
* Gets a session handle.
*/
public static function start()
{
if(!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Gets a session variable. Returns false if doesn't exist.
*/
public function get($varname)
{
if(array_key_exists($varname, $this->values)) {
return unserialize(base64_decode($this->values[$varname]));
} else {
return false;
}
}
/**
* Sets a session variable. Returns $value.
*/
public function set($varname, $value)
{
$value = base64_encode(serialize($value));
$this->values[$varname] = $value;
return $value;
}
/**
* Deletes a variable from the session.
*/
public function remove($varname)
{
unset($this->values[$varname]);
}
/**
* Deletes all this session container (not the session!)
*/
public static function dispose()
{
if(isset(self::$instance)) {
self::$instance = null;
return true;
} else {
return false;
}
}
}
?>