Class JSession

Description

Implements interfaces:

  • IteratorAggregate (internal interface)

Class for managing HTTP sessions

Provides access to session-state values as well as session-level settings and lifetime management methods. Based on the standard PHP session handling mechanism it provides more advanced features such as expire timeouts.

  • since: 11.1

Located in /libraries/joomla/session/session.php (line 24)


	
			
Variable Summary
Method Summary
 static boolean checkToken ([string $method = 'post'])
 static string getFormToken ([boolean $forceNew = false])
 static JSession getInstance (string $handler, array $options)
 static array getStores ()
 JSession __construct ([string $store = 'none'], [array $options = array()])
 mixed clear (string $name, [string $namespace = 'default'])
 void close ()
 boolean destroy ()
 boolean fork ()
 mixed get (string $name, [mixed $default = null], [string $namespace = 'default'])
 integer getExpire ()
 string getId ()
 ArrayIterator getIterator ()
 string getName ()
 string getState ()
 string getToken ([boolean $forceNew = false])
 boolean has (string $name, [string $namespace = 'default'])
 boolean hasToken (string $tCheck, [boolean $forceExpire = true])
 void. initialise (JInput $input, [JEventDispatcher $dispatcher = null])
 boolean isActive ()
 boolean isNew ()
 boolean restart ()
 mixed set (string $name, [mixed $value = null], [string $namespace = 'default'])
 void start ()
 string _createToken ([integer $length = 32])
 boolean _setCounter ()
 boolean _setOptions (array $options)
 boolean _setTimers ()
 boolean _start ()
 boolean _validate ([boolean $restart = false])
 mixed __get (string $name)
Variables
static JSession $instance (line 80)

JSession instances container.

  • since: 11.3
  • access: protected
string $storeName (line 88)

The type of storage for the session.

  • since: 12.2
  • access: protected
string $_expire = 15 (line 42)

Maximum age of unused session in minutes

  • since: 11.1
  • access: protected
boolean $_force_ssl = false (line 72)

Force cookies to be SSL only Default false

  • since: 11.1
  • access: protected
array $_security = array('fix_browser') (line 63)

Security policy.

List of checks that will be done.

Default values:

  • fix_browser
  • fix_adress

  • since: 11.1
  • access: protected
string $_state = 'inactive' (line 34)

Internal state.

One of 'inactive'|'active'|'expired'|'destroyed'|'error'

JSessionStorage $_store = null (line 50)

The session store object.

  • since: 11.1
  • access: protected
Methods
static checkToken (line 316)

Checks for a form token in the request.

Use in conjunction with JHtml::_('form.token') or JSession::getFormToken.

  • return: True if found and valid, false otherwise.
  • since: 12.1
  • access: public
static boolean checkToken ([string $method = 'post'])
  • string $method: The request method in which to look for the token key.
static getFormToken (line 275)

Method to determine a hash for anti-spoofing variable names

  • return: Hashed var name
  • since: 11.1
  • access: public
static string getFormToken ([boolean $forceNew = false])
  • boolean $forceNew: If true, force a new token to be created
static getInstance (line 176)

Returns the global Session object, only creating it if it doesn't already exist.

  • return: The Session object.
  • since: 11.1
  • access: public
static JSession getInstance (string $handler, array $options)
  • string $handler: The type of session handler.
  • array $options: An array of configuration options.
static getStores (line 382)

Get the session handlers

  • return: An array of available session handlers
  • since: 11.1
  • access: public
static array getStores ()
Constructor __construct (line 114)

Constructor

  • since: 11.1
  • access: public
JSession __construct ([string $store = 'none'], [array $options = array()])
  • string $store: The type of storage for the session.
  • array $options: Optional parameters
clear (line 561)

Unset data from the session store

  • return: The value from session or NULL if not set
  • since: 11.1
  • access: public
mixed clear (string $name, [string $namespace = 'default'])
  • string $name: Name of variable
  • string $namespace: Namespace to use, default to 'default'
close (line 787)

Writes session data and ends session

Session data is usually stored after your script terminated without the need to call JSession::close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.

void close ()
destroy (line 676)

Frees all session variables and destroys all data registered to a session

This method resets the $_SESSION variable and destroys all of the data associated with the current session in its storage (file or DB). It forces new session to be started after this method is called. It does not unset the session cookie.

boolean destroy ()
fork (line 744)

Create a new session and copy variables from the old one

  • return: true on success
  • since: 11.1
  • access: public
boolean fork ()
get (line 472)

Get data from the session store

  • return: Value of a variable
  • since: 11.1
  • access: public
mixed get (string $name, [mixed $default = null], [string $namespace = 'default'])
  • string $name: Name of a variable
  • mixed $default: Default value of a variable if not set
  • string $namespace: Namespace to use, default to 'default'
getExpire (line 205)

Get expiration time in minutes

  • return: The session expiration time in minutes
  • since: 11.1
  • access: public
integer getExpire ()
getId (line 365)

Get session id

  • return: The session name
  • since: 11.1
  • access: public
string getId ()
getIterator (line 300)

Retrieve an external iterator.

  • return: Return an ArrayIterator of $_SESSION.
  • since: 12.2
  • access: public
ArrayIterator getIterator ()

Implementation of:
IteratorAggregate::getIterator
getName (line 348)

Get session name

  • return: The session name
  • since: 11.1
  • access: public
string getName ()
getState (line 193)

Get current state of session

  • return: The session state
  • since: 11.1
  • access: public
string getState ()
getToken (line 223)

Get a session token, if a token isn't set yet one will be generated.

Tokens are used to secure forms from spamming attacks. Once a token has been generated the system will check the post request to see if it is present, if not it will invalidate the session.

  • return: The session token
  • since: 11.1
  • access: public
string getToken ([boolean $forceNew = false])
  • boolean $forceNew: If true, force a new token to be created
has (line 537)

Check whether data exists in the session store

  • return: True if the variable exists
  • since: 11.1
  • access: public
boolean has (string $name, [string $namespace = 'default'])
  • string $name: Name of variable
  • string $namespace: Namespace to use, default to 'default'
hasToken (line 248)

Method to determine if a token exists in the session. If not the session will be set to expired

  • since: 11.1
  • access: public
boolean hasToken (string $tCheck, [boolean $forceExpire = true])
  • string $tCheck: Hashed token to be verified
  • boolean $forceExpire: If true, expires the session
initialise (line 455)

Check whether this session is currently created

  • since: 12.2
  • access: public
void. initialise (JInput $input, [JEventDispatcher $dispatcher = null])
  • JInput $input: JInput object for the session to use.
  • JEventDispatcher $dispatcher: Dispatcher object for the session to use.
isActive (line 427)

Shorthand to check if the session is active

  • since: 12.2
  • access: public
boolean isActive ()
isNew (line 439)

Check whether this session is currently created

  • return: True on success.
  • since: 11.1
  • access: public
boolean isNew ()
restart (line 712)

Restart an expired or locked session.

boolean restart ()
set (line 502)

Set data into the session store.

  • return: Old value of a variable.
  • since: 11.1
  • access: public
mixed set (string $name, [mixed $value = null], [string $namespace = 'default'])
  • string $name: Name of a variable.
  • mixed $value: Value of a variable.
  • string $namespace: Namespace to use, default to 'default'.
start (line 589)

Start a session.

  • since: 12.2
  • access: public
void start ()
_createToken (line 830)

Create a token-string

  • return: Generated token
  • since: 11.1
  • access: protected
string _createToken ([integer $length = 32])
  • integer $length: Length of string
_setCookieParams (line 799)

Set session cookie parameters

  • since: 11.1
  • access: protected
void _setCookieParams ()
_setCounter (line 851)

Set counter of session usage

  • return: True on success
  • since: 11.1
  • access: protected
boolean _setCounter ()
_setOptions (line 893)

Set additional session options

  • return: True on success
  • since: 11.1
  • access: protected
boolean _setOptions (array $options)
  • array $options: List of parameter
_setTimers (line 867)

Set the session timers

  • return: True on success
  • since: 11.1
  • access: protected
boolean _setTimers ()
_start (line 622)

Start a session.

Creates a session (or resumes the current one based on the state of the session)

  • return: true on success
  • since: 11.1
  • access: protected
boolean _start ()
_validate (line 946)

Do some checks for security reason

  • timeout check (expire)
  • ip-fixiation
  • browser-fixiation
If one check failed, session data has to be cleaned.

boolean _validate ([boolean $restart = false])
  • boolean $restart: Reactivate session
__get (line 151)

Magic method to get read-only access to properties.

  • return: The value of the property
  • since: 12.2
  • access: public
mixed __get (string $name)
  • string $name: Name of property to retrieve

Documentation generated on Tue, 19 Nov 2013 15:12:52 +0100 by phpDocumentor 1.4.3