Class yii\authclient\SessionStateStorage

Inheritanceyii\authclient\SessionStateStorage » yii\base\Component
Implementsyii\authclient\StateStorageInterface
Available since extension's version2.1
Source Code https://github.com/yiisoft/yii2-authclient/blob/master/src/SessionStateStorage.php

SessionStateStorage provides Auth client state storage based on web session.

See also:

Public Properties

Hide inherited properties

Property Type Description Defined By
$session \yii\web\Session|array|string Session object or the application component ID of the session object to be used. yii\authclient\SessionStateStorage

Public Methods

Hide inherited methods

Method Description Defined By
get() Returns the state variable value with the variable name. yii\authclient\SessionStateStorage
init() yii\authclient\SessionStateStorage
remove() Removes a state variable. yii\authclient\SessionStateStorage
set() Adds a state variable. yii\authclient\SessionStateStorage

Property Details

Hide inherited properties

$session public property

Session object or the application component ID of the session object to be used.

After the SessionStateStorage object is created, if you want to change this property, you should only assign it with a session object.

If not set - application 'session' component will be used, but only, if it is available (e.g. in web application), otherwise - no session will be used and no data saving will be performed.

public \yii\web\Session|array|string $session null

Method Details

Hide inherited methods

get() public method

Returns the state variable value with the variable name.

public mixed get ( $key )
$key string

The variable name

return mixed

The variable value, or null if the variable does not exist.

                public function get($key)
{
    if ($this->session !== null) {
        return $this->session->get($key);
    }
    return null;
}

            
init() public method

public void init ( )

                public function init()
{
    parent::init();
    if ($this->session === null) {
        if (Yii::$app->has('session')) {
            $this->session = Yii::$app->get('session');
        }
    } else {
        $this->session = Instance::ensure($this->session, Session::className());
    }
}

            
remove() public method

Removes a state variable.

public boolean remove ( $key )
$key string

The name of the variable to be removed

return boolean

Success.

                public function remove($key)
{
    if ($this->session !== null) {
        $this->session->remove($key);
    }
    return true;
}

            
set() public method

Adds a state variable.

If the specified name already exists, the old value will be overwritten.

public void set ( $key, $value )
$key string

Variable name

$value mixed

Variable value

                public function set($key, $value)
{
    if ($this->session !== null) {
        $this->session->set($key, $value);
    }
}