Session

Extends \Joomla\Session\Session

Class for managing HTTP sessions

since

1.5

package

Application

Methods

__construct

Constructor

__construct(\Joomla\Session\StorageInterface store = null, \Joomla\Event\DispatcherInterface dispatcher = null, array options = []) : mixed
since

1.0

Arguments

store

\Joomla\Session\StorageInterfaceA StorageInterface implementation.

dispatcher

\Joomla\Event\DispatcherInterfaceDispatcherInterface for the session to use.

options

arrayOptional 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(string method = 'post') : bool
static

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() : void
since

1.5

get

Get data from the session store

get(string name, mixed default = null) : mixed
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(bool forceNew = false) : string
static
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() : array
static
since

4.0.0

Response

arrayAn array of available session handlers

getInstance

Returns the global session object.

getInstance() : static
static deprecated
since

1.5

deprecated

5.0 Load the session service from the dependency injection container or via $app->getSession()

Response

staticThe Session object.

has

Check whether data exists in the session store

has(string name) : bool
since

1.5

Arguments

name

stringName of variable

Response

boolTrue if the variable exists

set

Set data into the session store.

set(string name, mixed value = null) : mixed
since

1.5

Arguments

name

stringName of a variable.

value

mixedValue of a variable.

Response

mixedOld value of a variable.