Session
扩展 Session用于管理 HTTP 会话的类
| 自 |
1.5 |
|---|---|
| 包 |
Joomla CMS |
方法
__construct
构造函数
__construct(\Joomla\Session\StorageInterface store = null, \Joomla\Event\DispatcherInterface dispatcher = null, mixed||string|int options = []) :
| 自 |
1.0 |
|---|
参数
- store
StorageInterfaceStorageInterface 实现。- dispatcher
DispatcherInterface会话使用的 DispatcherInterface。- options
array<string|int, mixed>可选参数。支持的键包括- name: 会话名称
- id: 会话 ID
- expire: 会话生命周期(秒)
响应
混合
checkToken
检查请求中是否存在表单令牌。
checkToken( method = 'post') :
静态
与 HTMLHelper::_('form.token') 或 JSession::getFormToken 结合使用。
| 自 |
2.5.4 |
|---|
参数
- 方法
string要查找令牌键的请求方法。
响应
bool如果找到且有效,则为 true,否则为 false。
clear
清除会话存储中的所有变量
clear() :
| 自 |
1.5 |
|---|
响应
空
get
从会话存储中获取数据
get( name, default = null) :
| 自 |
1.5 |
|---|
参数
- name
string变量的名称- default
mixed如果未设置,则为变量的默认值
响应
mixed变量的值
getFormToken
确定用于反欺骗变量名称的哈希的方法
getFormToken( forceNew = false) :
静态
| 自 |
1.6 |
|---|
参数
- forceNew
bool如果为 true,则强制创建新的令牌
响应
string哈希的变量名称
getHandlers
获取可用的会话处理程序
getHandlers() : mixed||string|int
静态
| 自 |
4.0.0 |
|---|
响应
array<string|int, mixed>可用会话处理程序的数组
getInstance
返回全局会话对象。
getInstance() :
静态 已弃用
| 自 |
1.5 |
|---|---|
| 已弃用 |
4.3 将在 6.0 中移除 从依赖注入容器或通过 $app->getSession() 加载会话服务 示例:Factory::getApplication()->getSession(); |
响应
static会话对象。
has
检查会话存储中是否存在数据
has( name) :
| 自 |
1.5 |
|---|
参数
- name
string变量的名称
响应
bool如果变量存在,则为 true
set
将数据设置到会话存储中。
set( name, value = null) :
| 自 |
1.5 |
|---|
参数
- name
string变量的名称。- value
mixed变量的值。
响应
mixed变量的旧值。