Session核心类
API - Module_Session
- Session::$config
- Session::instance
- Session::__construct
- Session::start - 开启SESSION
- Session::id - 获取SESSION ID
- Session::destroy - 销毁当前Session
- Session::set_member - 设置用户
- Session::member_id - 返回当前用户id
- Session::member - 获取用户对象
- Session::last_actived_time - 最后活动时间
- Session::set - 设置SESSION数据
- Session::set_flash - 设置一个闪存SESSION数据,在下次请求的时候会获取后自动销毁
- Session::keep_flash - 保持闪存SESSION数据不销毁
- Session::expire_flash - 标记闪存SESSION数据为过期
- Session::get - 获取一个SESSION数据
- Session::get_once - 获取后删除相应KEY的SESSION数据
- Session::delete - 删除指定key的SESSION数据
- Session::write_close - 此方法用于保存session数据
- Session::session_name - 获取SESSION名称
- Session::create_session_id - 生成一个新的Session ID
- Session::check_session_id - 检查当前Session ID是否合法
Session
开启SESSION
Session
获取SESSION ID
string
销毁当前Session
void
设置用户
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$member |
Member |
$member |
Session
返回当前用户id
int
获取用户对象
Member
最后活动时间
int
设置SESSION数据
Session::instance()->set('key','value');
Session::instance()->set(array('key'=>'value','k2'=>'v2'));
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$keys |
string|array |
Key, or array of values | |
$val |
mixed |
Value (if keys is not an array) | bool false |
void
设置一个闪存SESSION数据,在下次请求的时候会获取后自动销毁
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$keys |
string|array |
Key, or array of values | |
$val |
mixed |
Value (if keys is not an array) | bool false |
void
保持闪存SESSION数据不销毁
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$keys |
string |
Variable key(s) | null |
void
标记闪存SESSION数据为过期
void
获取一个SESSION数据
Session::instance()->get('key');
Session::instance()->get('key','default value');
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
Variable key | bool false |
$default |
mixed |
Default value returned if variable does not exist | bool false |
mixed
Variable data if key specified, otherwise array containing all session data.获取后删除相应KEY的SESSION数据
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key |
string |
Variable key | |
$default |
mixed |
Default value returned if variable does not exist | bool false |
mixed
删除指定key的SESSION数据
Session::instance()->delete('key');
//删除key1和key2的数据
Session::instance()->delete('key1','key2');
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$key1 |
string |
Variable key(s) | null |
$key2 |
unknown |
null |
void
此方法用于保存session数据
系统在关闭前会执行
void
获取SESSION名称
生成一个新的Session ID
string
返回一个32长度的session id检查当前Session ID是否合法
参数 | 类型 | 描述 | 默认值 |
---|---|---|---|
$sid |
string |
$sid |
boolean