会话管理
namespace ginkgo;
class Session {
// 属性
public static $config = array();
private static $configThis = array(
'autostart' => false,
'name' => '',
'type' => 'file',
'path' => '',
'prefix' => 'ginkgo_',
'cookie_domain' => '',
'life_time' => 1200,
);
private static $init;
// 方法
public static init( [ array $config ] )
public static config( array $config )
public static prefix( [ string $prefix ] ) : string
public static set( string $name, string $value [, string $prefix ] )
public static get( string $name, string [, string $prefix ] ) : string
public static delete( string $name, string [, string $prefix ] )
private static prefixProcess( string $prefix ) : array
}
- | 权限 | 类型 | 描述 |
---|---|---|---|
属性 | - | - | - |
$config |
public | array static | 配置 0.2.0 新增 |
$configThis |
private | array static | 默认配置 0.2.0 新增 |
$init |
private | bool static | 是否初始化标志 |
方法 | - | - | - |
init() | public | static | 初始化 |
config() | public | static | 配置 0.2.0 新增 |
prefix() | public | static | 设置、获取前缀 |
set() | public | static | 设置会话变量 |
get() | public | static | 获取会话变量 |
delete() | public | static | 删除会话变量 |
prefixProcess() | private | static | 前缀处理 |
$config
配置,$configThis
默认配置0.2.0
新增
public static $config;
private static $configThis;
结构
名称 | 类型 | 默认 | 描述 |
---|---|---|---|
autostart | bool | false | 是否自动开始 |
name | string | Session ID 名称 | |
type | string | file | 会话类型 |
path | string | 保存路径(仅对 file 类型有效) | |
prefix | string | ginkgo_ | 会话前缀 |
cookie_domain | string | 设定会话 cookie 的域名 | |
life_time | string | 1200 | 会话生命周期 |
init()
初始化public static function init( [ array $config ] )
参数
config
配置参数返回
config()
配置0.2.0
新增
public static function config( array $config )
参数
config
配置参数返回
prefix()
设置、获取前缀public static function prefix( [ string $prefix ] ) : string
参数
prefix
前缀,支持二级前缀,两级前缀之间用 . 隔开,为空时返回前缀返回
set()
设置会话变量public static function set( string $name, string $value [, string $prefix ] )
参数
name
变量名value
变量值prefix
前缀返回
get()
获取会话变量public static function get( string $name, string [, string $prefix ] ) : string
参数
name
变量名prefix
前缀返回
delete()
删除会话变量public static function delete( string $name, string [, string $prefix ] )
参数
name
变量名prefix
前缀返回
prefixProcess()
前缀处理private static function prefixProcess( string $prefix ) : array
参数
prefix
前缀返回