JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • Session
  • Storage

Class Session

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.

Joomla\Session\Session implements IteratorAggregate
Namespace: Joomla\Session
Since: 1.0
Located at vendor/joomla/session/Joomla/Session/Session.php

Methods summary

public
# __construct( string $store = 'none', array $options = array() )

Constructor

Constructor

Parameters

$store
string - $store The type of storage for the session.
$options
array - $options Optional parameters

Since

1.0
public mixed
# __get( string $name )

Magic method to get read-only access to properties.

Magic method to get read-only access to properties.

Deprecated

2.0 Use get methods for non-deprecated properties

Parameters

$name
string - $name Name of property to retrieve

Returns

mixed - The value of the property

Since

1.0
public static Joomla\Session\Session
# getInstance( string $handler, array $options = array () )

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

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

Deprecated

2.0 A singleton object store will no longer be supported

Parameters

$handler
string - $handler The type of session handler.
$options
array - $options An array of configuration options (for new sessions only).

Returns

Joomla\Session\Session - The Session object.

Since

1.0
public string
# getState( )

Get current state of session

Get current state of session

Returns

string - The session state

Since

1.0
public integer
# getExpire( )

Get expiration time in minutes

Get expiration time in minutes

Returns

integer - The session expiration time in minutes

Since

1.0
public string
# getToken( boolean $forceNew = false )

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

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.

Parameters

$forceNew
boolean - $forceNew If true, force a new token to be created

Returns

string - The session token

Since

1.0
public boolean
# hasToken( string $tCheck, boolean $forceExpire = true )

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

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

Parameters

$tCheck
string - $tCheck Hashed token to be verified
$forceExpire
boolean - $forceExpire If true, expires the session

Returns

boolean

Since

1.0
public ArrayIterator
# getIterator( )

Retrieve an external iterator.

Retrieve an external iterator.

Returns

ArrayIterator - Return an ArrayIterator of $_SESSION.

Since

1.0

Implementation of

IteratorAggregate::getIterator()
public string
# getName( )

Get session name

Get session name

Returns

string - The session name

Since

1.0
public string
# getId( )

Get session id

Get session id

Returns

string - The session name

Since

1.0
public static array
# getStores( )

Get the session handlers

Get the session handlers

Deprecated

2.0 The Storage class chain will be removed

Returns

array - An array of available session handlers

Since

1.0
public boolean
# isActive( )

Shorthand to check if the session is active

Shorthand to check if the session is active

Returns

boolean

Since

1.0
public boolean
# isNew( )

Check whether this session is currently created

Check whether this session is currently created

Returns

boolean - True on success.

Since

1.0
public
# initialise( Joomla\Input\Input $input, Joomla\Event\DispatcherInterface $dispatcher = null )

Check whether this session is currently created

Check whether this session is currently created

Deprecated

2.0 In 2.0 the DispatcherInterface should be injected via the object constructor

Parameters

$input
Joomla\Input\Input - $input Input object for the session to use.
$dispatcher
Joomla\Event\DispatcherInterface - $dispatcher Dispatcher object for the session to use.

Since

1.0
public mixed
# get( string $name, mixed $default = null, string $namespace = 'default' )

Get data from the session store

Get data from the session store

Parameters

$name
string - $name Name of a variable
$default
mixed - $default Default value of a variable if not set
$namespace
string - $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}

Returns

mixed - Value of a variable

Since

1.0
public mixed
# set( string $name, mixed $value = null, string $namespace = 'default' )

Set data into the session store.

Set data into the session store.

Parameters

$name
string - $name Name of a variable.
$value
mixed - $value Value of a variable.
$namespace
string - $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}

Returns

mixed - Old value of a variable.

Since

1.0
public boolean
# has( string $name, string $namespace = 'default' )

Check whether data exists in the session store

Check whether data exists in the session store

Parameters

$name
string - $name Name of variable
$namespace
string - $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}

Returns

boolean - True if the variable exists

Since

1.0
public mixed
# clear( string $name, string $namespace = 'default' )

Unset data from the session store

Unset data from the session store

Parameters

$name
string - $name Name of variable
$namespace
string - $namespace Namespace to use, default to 'default' {@deprecated 2.0 Namespace support will be removed.}

Returns

mixed - The value from session or NULL if not set

Since

1.0
public
# start( )

Start a session.

Start a session.

Since

1.0
protected boolean
# _start( )

Start a session.

Start a session.

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

Deprecated

2.0

Returns

boolean - true on success

Since

1.0
public boolean
# destroy( )

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

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.

Returns

boolean - True on success

Since

1.0

See

session_destroy()
session_unset()
public boolean
# restart( )

Restart an expired or locked session.

Restart an expired or locked session.

Returns

boolean - True on success

Since

1.0

See

Joomla\Session\Session::destroy()
public boolean
# fork( )

Create a new session and copy variables from the old one

Create a new session and copy variables from the old one

Returns

boolean - $result true on success

Since

1.0
public
# close( )

Writes session data and ends session

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.

Since

1.0

See

session_write_close()
protected mixed
# setExpire( integer $expire )

Set the session expiration

Set the session expiration

Parameters

$expire
integer - $expire Maximum age of unused session in minutes

Returns

mixed - $this

Since

1.3.0
protected mixed
# setState( string $state )

Set the session state

Set the session state

Parameters

$state
string - $state Internal state

Returns

mixed - $this

Since

1.3.0
protected
# _setCookieParams( )

Set session cookie parameters

Set session cookie parameters

Deprecated

2.0

Since

1.0
protected string
# _createToken( integer $length = 32 )

Create a token-string

Create a token-string

Deprecated

2.0 Use createToken instead

Parameters

$length
integer - $length Length of string

Returns

string - Generated token

Since

1.0
protected string
# createToken( integer $length = 32 )

Create a token-string

Create a token-string

Parameters

$length
integer - $length Length of string

Returns

string - Generated token

Since

1.3.1
protected boolean
# _setCounter( )

Set counter of session usage

Set counter of session usage

Deprecated

2.0 Use setCounter instead

Returns

boolean - True on success

Since

1.0
protected boolean
# setCounter( )

Set counter of session usage

Set counter of session usage

Returns

boolean - True on success

Since

1.3.0
protected boolean
# _setTimers( )

Set the session timers

Set the session timers

Deprecated

2.0 Use setTimers instead

Returns

boolean - True on success

Since

1.0
protected boolean
# setTimers( )

Set the session timers

Set the session timers

Returns

boolean - True on success

Since

1.3.0
protected boolean
# _setOptions( array $options )

Set additional session options

Set additional session options

Deprecated

2.0 Use setOptions instead

Parameters

$options
array - $options List of parameter

Returns

boolean - True on success

Since

1.0
protected boolean
# setOptions( array $options )

Set additional session options

Set additional session options

Parameters

$options
array - $options List of parameter

Returns

boolean - True on success

Since

1.3.0
protected boolean
# _validate( boolean $restart = false )

Do some checks for security reason

Do some checks for security reason

  • timeout check (expire)
  • ip-fixiation
  • browser-fixiation

If one check failed, session data has to be cleaned.

Deprecated

2.0 Use validate instead

Parameters

$restart
boolean - $restart Reactivate session

Returns

boolean - True on success

Since

1.0

See

http://shiflett.org/articles/the-truth-about-sessions
protected boolean
# validate( boolean $restart = false )

Do some checks for security reason

Do some checks for security reason

  • timeout check (expire)
  • ip-fixiation
  • browser-fixiation

If one check failed, session data has to be cleaned.

Parameters

$restart
boolean - $restart Reactivate session

Returns

boolean - True on success

Since

1.3.0

See

http://shiflett.org/articles/the-truth-about-sessions

Magic methods summary

Properties summary

protected string $state
#

Internal state. One of 'inactive'|'active'|'expired'|'destroyed'|'error'

Internal state. One of 'inactive'|'active'|'expired'|'destroyed'|'error'

Since

1.0

See

Joomla\Session\Session::getState()
protected string $expire
#

Maximum age of unused session in minutes

Maximum age of unused session in minutes

Since

1.0
protected Joomla\Session\Storage $store
#

The session store object.

The session store object.

Since

1.0
protected array $security
#

Security policy. List of checks that will be done.

Security policy. List of checks that will be done.

Default values:

  • fix_browser
  • fix_adress

Since

1.0
protected boolean $force_ssl
#

Force cookies to be SSL only Default false

Force cookies to be SSL only Default false

Since

1.0
protected mixed $cookie_domain
#

The domain to use when setting cookies.

The domain to use when setting cookies.

Deprecated

2.0

Since

1.0
protected mixed $cookie_path
#

The path to use when setting cookies.

The path to use when setting cookies.

Deprecated

2.0

Since

1.0
protected static Joomla\Session\Session $instance
#

Session instances container.

Session instances container.

Deprecated

2.0

Since

1.0
protected string $storeName
#

The type of storage for the session.

The type of storage for the session.

Deprecated

2.0

Since

1.0
Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.