Session
Extends SessionClass for managing HTTP sessions
| since |
1.5 |
|---|---|
| package |
Joomla CMS |
Methods
__construct
Constructor
__construct(\Joomla\Session\StorageInterface store = null, \Joomla\Event\DispatcherInterface dispatcher = null, mixed||string|int options = []) :
| since |
1.0 |
|---|
Arguments
- store
StorageInterface|nullA StorageInterface implementation.- dispatcher
DispatcherInterface|nullDispatcherInterface for the session to use.- options
array<string|int, mixed>Optional parameters. Supported keys include:- name: The session name
- id: The session ID
- expire: The session lifetime in seconds
Response
mixed
checkToken
Checks for a form token in the request.
checkToken( method = 'post') :
Use in conjunction with HTMLHelper::_('form.token') or JSession::getFormToken.
| since |
2.5.4 |
|---|
Arguments
- method
stringThe request method in which to look for the token key.
Response
boolTrue if found and valid, false otherwise.
clear
Clears all variables from the session store
clear() :
| since |
1.5 |
|---|
Response
void
get
Get data from the session store
get( name, default = null) :
| since |
1.5 |
|---|
Arguments
- name
stringName of a variable- default
mixedDefault value of a variable if not set
Response
mixedValue of a variable
getFormToken
Method to determine a hash for anti-spoofing variable names
getFormToken( forceNew = false) :
| since |
1.6 |
|---|
Arguments
- forceNew
boolIf true, force a new token to be created
Response
stringHashed var name
getHandlers
Get the available session handlers
getHandlers() : mixed||string|int
| since |
4.0.0 |
|---|
Response
array<string|int, mixed>An array of available session handlers
getInstance
Returns the global session object.
getInstance() :
| since |
1.5 |
|---|---|
| deprecated |
4.3 will be removed in 6.0 Load the session service from the dependency injection container or via $app->getSession() Example: Factory::getApplication()->getSession(); |
Response
staticThe Session object.
has
Check whether data exists in the session store
has( name) :
| since |
1.5 |
|---|
Arguments
- name
stringName of variable
Response
boolTrue if the variable exists
set
Set data into the session store.
set( name, value = null) :
| since |
1.5 |
|---|
Arguments
- name
stringName of a variable.- value
mixedValue of a variable.
Response
mixedOld value of a variable.