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
A StorageInterface implementation.- dispatcher
DispatcherInterface
DispatcherInterface 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
string
The request method in which to look for the token key.
Response
bool
True 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
string
Name of a variable- default
mixed
Default value of a variable if not set
Response
mixed
Value of a variable
getFormToken
Method to determine a hash for anti-spoofing variable names
getFormToken( forceNew = false) :
since |
1.6 |
---|
Arguments
- forceNew
bool
If true, force a new token to be created
Response
string
Hashed 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
static
The Session object.
has
Check whether data exists in the session store
has( name) :
since |
1.5 |
---|
Arguments
- name
string
Name of variable
Response
bool
True if the variable exists
set
Set data into the session store.
set( name, value = null) :
since |
1.5 |
---|
Arguments
- name
string
Name of a variable.- value
mixed
Value of a variable.
Response
mixed
Old value of a variable.