技术支持:KUOQPS@163.com
-

kuoqi\session

更新时间:2019-12-13 14:11:26 | 简介:library/session描述
/**
*create:kuoqi
*version:1.01
*createTime:2019-08-05
*remark:session相关信息
*/
namespace Kuoqi;
/**
* Class Session
* @package Kuoqi
*/
class Session{
/**
* __initialize
* create By:kuoqi
* @return Session
* @throws error
* remark:
*/
static function __initialize()
{
$url = ini_get('session.save_path');
if(!is_dir($url)){
ini_set('session.save_path',"./public/session");
$url = ini_get('session.save_path');
if(!is_dir($url)){
throw new \kuoqi\error("session[{$url}]存储路径不存在或不可读","debug");
}
}
isset($_SESSION)||session_start();
}
/**
* Session constructor.
* @throws error
*/
public function __construct()
{}
/**
* set
* create By:kuoqi
* @param $name
* @param $code
* remark:
*/
static public function set($name,$code)
{
$_SESSION[$name] = $code;
}
/**
* get
* create By:kuoqi
* @param $name
* @return mixed|null
* remark:
*/
static public function get($name)
{
return isset($_SESSION[$name])?$_SESSION[$name]:NULL;
}
/**
* del
* create By:kuoqi
* @param $name
* @return null
* remark:
*/
static public function del($name)
{
if(isset($_SESSION[$name]))
unset($_SESSION[$name]);
return null;
}
/**
* destroy
* create By:kuoqi
* remark:
*/
static public function destroy()
{
session_destroy();
}
}