参数配置

参数名 说明 是否可选 默认值
cache_expire 到期时间,以分钟为单位 null
cache_limiter 缓存限制器 null
module_name 会话模块名称 null
name 会话名称 null
register_shutdown 注册关闭会话 null
save_path 保存路径 null
cookie_params cookie 参数 []
cookie_params.lifetime Cookie 的生命周期,以秒为单位。
cookie_params.path cookie 的有效路径 null
cookie_params.domain Cookie 的作用域 null
cookie_params.secure cookie 是否仅在使用安全链接时可用 false
cookie_params.httponly cookie 是否使用 httponly 标记 false
save_handler 会话存储配置
save_handler.type 会话处理器名称,`files`也表示系统默认 “”
save_handler.config 处理器配置 []
save_handler.register_shutdown 处理器是否注册关闭会话 true
options 会话配置 []

注解

FizeSession 的配置参数基本和 PHP 底层的 session 方法参数一致,除了以下几点:

  • cookie_params 扩展为数组类型。
  • 添加参数 save_handler 。
  • options 参数请参考 session_start($options) PHP 官方手册。
  • save_handler.config 参数请参考 处理器配置
$config = [
        'name'              => 'my_php_session_id',
        'save_handler'      => [
                'type'              => 'Database',
                'config'            => [
                        'db' => [
                                'type' => 'mysql',
                                'config' => [
                                        'host'     => 'localhost',
                                        'user'     => 'root',
                                        'password' => '123456',
                                        'dbname'   => 'gm_test'
                                ]
                        ],
                        'table' => 'sys_session'
                ],
                'register_shutdown' => true
        ]
];