PHP Класс yii\web\CacheSession

The cache being used can be any cache application component. The ID of the cache application component is specified via [[cache]], which defaults to 'cache'. Beware, by definition cache storage are volatile, which means the data stored on them may be swapped out and get lost. Therefore, you must make sure the cache used by this component is NOT volatile. If you want to use database as storage medium, DbSession is a better choice. The following example shows how you can configure the application to use CacheSession: Add the following to your application config under components: php 'session' => [ 'class' => 'yii\web\CacheSession', 'cache' => 'mycache', ]
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends yii\web\Session
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$cache the cache object or the application component ID of the cache object. The session data will be stored using this cache object. After the CacheSession object is created, if you want to change this property, you should only assign it with a cache object. Starting from version 2.0.2, this can also be a configuration array for creating the object.

Открытые методы

Метод Описание
destroySession ( string $id ) : boolean Session destroy handler.
getUseCustomStorage ( ) : boolean Returns a value indicating whether to use custom session storage.
init ( ) Initializes the application component.
readSession ( string $id ) : string Session read handler.
writeSession ( string $id, string $data ) : boolean Session write handler.

Защищенные методы

Метод Описание
calculateKey ( string $id ) : mixed Generates a unique key used for storing session data in cache.

Описание методов

calculateKey() защищенный Метод

Generates a unique key used for storing session data in cache.
protected calculateKey ( string $id ) : mixed
$id string session variable name
Результат mixed a safe cache key associated with the session variable name

destroySession() публичный Метод

Do not call this method directly.
public destroySession ( string $id ) : boolean
$id string session ID
Результат boolean whether session is destroyed successfully

getUseCustomStorage() публичный Метод

This method overrides the parent implementation and always returns true.
public getUseCustomStorage ( ) : boolean
Результат boolean whether to use custom storage.

init() публичный Метод

Initializes the application component.
public init ( )

readSession() публичный Метод

Do not call this method directly.
public readSession ( string $id ) : string
$id string session ID
Результат string the session data

writeSession() публичный Метод

Do not call this method directly.
public writeSession ( string $id, string $data ) : boolean
$id string session ID
$data string session data
Результат boolean whether session write is successful

Описание свойств

$cache публичное свойство

the cache object or the application component ID of the cache object. The session data will be stored using this cache object. After the CacheSession object is created, if you want to change this property, you should only assign it with a cache object. Starting from version 2.0.2, this can also be a configuration array for creating the object.
public $cache