Class yii\authclient\SessionStateStorage
Inheritance | yii\authclient\SessionStateStorage » yii\base\Component |
---|---|
Implements | yii\authclient\StateStorageInterface |
Available since extension's version | 2.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:
- yii\authclient\StateStorageInterface
- \yii\web\Session
Public 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
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
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.
Method Details
Returns the state variable value with the variable name.
public mixed get ( $key ) | ||
$key | string |
The variable name |
return | mixed |
The variable value, or |
---|
public function get($key)
{
if ($this->session !== null) {
return $this->session->get($key);
}
return null;
}
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());
}
}
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;
}