新增
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\helper\Arr;
|
||||
use think\session\Store;
|
||||
|
||||
/**
|
||||
* Session管理类
|
||||
* @package think
|
||||
* @mixin Store
|
||||
*/
|
||||
class Session extends Manager
|
||||
{
|
||||
protected $namespace = '\\think\\session\\driver\\';
|
||||
|
||||
protected function createDriver(string $name)
|
||||
{
|
||||
$handler = parent::createDriver($name);
|
||||
|
||||
return new Store($this->getConfig('name') ?: 'PHPSESSID', $handler, $this->getConfig('serialize'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Session配置
|
||||
* @access public
|
||||
* @param null|string $name 名称
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name = null, $default = null)
|
||||
{
|
||||
if (!is_null($name)) {
|
||||
return $this->app->config->get('session.' . $name, $default);
|
||||
}
|
||||
|
||||
return $this->app->config->get('session');
|
||||
}
|
||||
|
||||
protected function resolveConfig(string $name)
|
||||
{
|
||||
$config = $this->app->config->get('session', []);
|
||||
Arr::forget($config, 'type');
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认驱动
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app->config->get('session.type', 'file');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user