class MySessionHandler implements SessionHandlerInterface
{
private $redis;
private $sessionsavepath;
private $sessionname;
public function __construct()
{
$this->redis = new Redis();
$this->redis->connect('127.0.0.1',6379);
}
public function close()
{
return true;
}
public function destroy($session_id)
{
if($this->redis->delete($session_id)){
return true;
}
return false;
}
public function gc($maxlifetime)
{
return true;
}
public function open($sessionsavepath, $name)
{
return true;
}
public function read($session_id)
{
if($value = $this->redis->get($session_id)){
return $value;
}else{
return false;
}
}
public function write($session_id, $session_data)
{
if($this->redis->set($session_id,$session_data,60)){
return true;
}else{
return false;
}
}
}
$handler = new MySessionHandler();
session_set_save_handler($handler, true);
session_start();
//$_SESSION['sess_name'] = 'xd';
var_dump($_SESSION);
分类:
程序积累
/
浏览量: 1501
2017-12-6 23:25 Wednesday
昵称
邮件地址 (选填)
个人主页 (选填)
评论内容
发表评论
send