PHP Class Contao\Session

The class functions as an adapter for the PHP $_SESSION array and separates back end from front end session data. Usage: $session = Session::getInstance(); $session->set('foo', 'bar'); echo $session->get('foo');
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use the session service instead.
Afficher le fichier Open project: contao/core-bundle Class Usage Examples

Protected Properties

Свойство Type Description
$objInstance Session Object instance (Singleton)

Méthodes publiques

Méthode Description
__clone ( ) Prevent cloning of the object (Singleton)
appendData ( mixed $varData ) Append data to the session
get ( string $strKey ) : mixed Return a session variable
getData ( ) : array Return the session data as array
getInstance ( ) : Session Return the object instance (Singleton)
remove ( string $strKey ) Remove a session variable
set ( string $strKey, mixed $varValue ) Set a session variable
setData ( array $arrData ) Set the session data from an array

Méthodes protégées

Méthode Description
__construct ( ) Get the session data

Private Methods

Méthode Description
getSessionBagKey ( ) : string Gets the correct session bag key depending on the Contao environment

Method Details

__clone() final public méthode

Prevent cloning of the object (Singleton)
final public __clone ( )

__construct() protected méthode

Get the session data
protected __construct ( )

appendData() public méthode

Append data to the session
public appendData ( mixed $varData )
$varData mixed The data object or array

get() public méthode

Return a session variable
public get ( string $strKey ) : mixed
$strKey string The variable name
Résultat mixed The variable value

getData() public méthode

Return the session data as array
public getData ( ) : array
Résultat array The session data

getInstance() public static méthode

Return the object instance (Singleton)
public static getInstance ( ) : Session
Résultat Session The object instance

remove() public méthode

Remove a session variable
public remove ( string $strKey )
$strKey string The variable name

set() public méthode

Set a session variable
public set ( string $strKey, mixed $varValue )
$strKey string The variable name
$varValue mixed The variable value

setData() public méthode

Set the session data from an array
public setData ( array $arrData )
$arrData array The session data

Property Details

$objInstance protected_oe static_oe property

Object instance (Singleton)
protected static Session,contao $objInstance
Résultat Session