# CacheSession

> CacheSession implements a session component using cache as storage medium.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [web](/docs/api/yii/web/index.md) › CacheSession

| class | `yii\web\CacheSession` |
| --- | --- |
| Extends | [`Session`](/docs/api/yii/web/session/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md), [`IteratorAggregate`](https://www.php.net/manual/en/class.iteratoraggregate.php), [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php), [`Countable`](https://www.php.net/manual/en/class.countable.php) |
| Since | 2.0 |
| Source | [`framework/web/CacheSession.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/web/CacheSession.php#L39) |

CacheSession implements a session component using cache as storage medium.

The cache being used can be any cache application component.
The ID of the cache application component is specified via [`$cache`](/docs/api/yii/web/cachesession/index.md#property-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`](/docs/api/yii/web/dbsession/index.md) 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`:

```
'session' => [
    'class' => 'yii\web\CacheSession',
    // 'cache' => 'mycache',
]
```

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-allFlashes"></span>[`$allFlashes`](/docs/api/yii/web/session/index.md#property-allFlashes) read-only | `array` | Flash messages (key => message or key => [message1, message2]). | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`$cache`](#property-cache) | [`yii\caching\CacheInterface`](/docs/api/yii/caching/cacheinterface/index.md)`\|array\|string` | The cache object or the application component ID of the cache object. Default: `'cache'`. | `CacheSession` |
| <span id="property-cacheLimiter"></span>[`$cacheLimiter`](/docs/api/yii/web/session/index.md#property-cacheLimiter) | `string` | Current cache limiter. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-cookieParams"></span>[`$cookieParams`](/docs/api/yii/web/session/index.md#property-cookieParams) | `array` | The session cookie parameters. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-count"></span>[`$count`](/docs/api/yii/web/session/index.md#property-count) read-only | `int` | The number of session variables. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-flash"></span>[`$flash`](/docs/api/yii/web/session/index.md#property-flash) write-only | `string` | The key identifying the flash message. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-flashParam"></span>[`$flashParam`](/docs/api/yii/web/session/index.md#property-flashParam) | `string` | The name of the session variable that stores the flash message data. Default: `'__flash'`. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-gCProbability"></span>[`$gCProbability`](/docs/api/yii/web/session/index.md#property-gCProbability) | `float` | The probability (percentage) that the GC (garbage collection) process is started on every session initialization. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-handler"></span>[`$handler`](/docs/api/yii/web/session/index.md#property-handler) | [`SessionHandlerInterface`](https://www.php.net/manual/en/class.sessionhandlerinterface.php)`\|array` | An object implementing the SessionHandlerInterface or a configuration array. Default: `null`. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-hasSessionId"></span>[`$hasSessionId`](/docs/api/yii/web/session/index.md#property-hasSessionId) | `bool` | Whether the current request has sent the session ID. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-id"></span>[`$id`](/docs/api/yii/web/session/index.md#property-id) | `string` | The current session ID. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-isActive"></span>[`$isActive`](/docs/api/yii/web/session/index.md#property-isActive) read-only | `bool` | Whether the session has started. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-iterator"></span>[`$iterator`](/docs/api/yii/web/session/index.md#property-iterator) read-only | [`SessionIterator`](/docs/api/yii/web/sessioniterator/index.md) | An iterator for traversing the session variables. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-name"></span>[`$name`](/docs/api/yii/web/session/index.md#property-name) | `string` | The current session name. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-savePath"></span>[`$savePath`](/docs/api/yii/web/session/index.md#property-savePath) | `string` | The current session save path, defaults to '/tmp'. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-timeout"></span>[`$timeout`](/docs/api/yii/web/session/index.md#property-timeout) | `int` | The number of seconds after which data will be seen as 'garbage' and cleaned up. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-useCookies"></span>[`$useCookies`](/docs/api/yii/web/session/index.md#property-useCookies) | `bool\|null` | The value indicating whether cookies should be used to store session IDs. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-useCustomStorage"></span>`$useCustomStorage` read-only | `bool` | Whether to use custom storage. | `CacheSession` |
| <span id="property-useStrictMode"></span>[`$useStrictMode`](/docs/api/yii/web/session/index.md#property-useStrictMode) | `bool` | Whether strict mode is enabled or not. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-useTransparentSessionID"></span>[`$useTransparentSessionID`](/docs/api/yii/web/session/index.md#property-useTransparentSessionID) | `bool` | Whether transparent sid support is enabled or not, defaults to false. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-_forceRegenerateId"></span>[`$_forceRegenerateId`](/docs/api/yii/web/session/index.md#property-_forceRegenerateId) protected | `string\|null` | Holds the session id in case useStrictMode is enabled and the session id needs to be regenerated Default: `null`. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="property-_originalSessionModule"></span>[`$_originalSessionModule`](/docs/api/yii/web/session/index.md#property-_originalSessionModule) protected static | `string\|null` | Holds the original session module (before a custom handler is registered) so that it can be restored when a Session component without custom handler is used after one that has. Default: `null`. | [`Session`](/docs/api/yii/web/session/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-addFlash"></span>[`addFlash()`](/docs/api/yii/web/session/index.md#method-addFlash) | Adds a flash message. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-close"></span>[`close()`](/docs/api/yii/web/session/index.md#method-close) | Ends the current session and store session data. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-count"></span>[`count()`](/docs/api/yii/web/session/index.md#method-count) | Returns the number of items in the session. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-destroy"></span>[`destroy()`](/docs/api/yii/web/session/index.md#method-destroy) | Frees all session variables and destroys all data registered to a session. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-get"></span>[`get()`](/docs/api/yii/web/session/index.md#method-get) | Returns the session variable value with the session variable name. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getAllFlashes"></span>[`getAllFlashes()`](/docs/api/yii/web/session/index.md#method-getAllFlashes) | Returns all flash messages. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getCacheLimiter"></span>[`getCacheLimiter()`](/docs/api/yii/web/session/index.md#method-getCacheLimiter) | Returns current cache limiter | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getCookieParams"></span>[`getCookieParams()`](/docs/api/yii/web/session/index.md#method-getCookieParams) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getCount"></span>[`getCount()`](/docs/api/yii/web/session/index.md#method-getCount) | Returns the number of items in the session. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getFlash"></span>[`getFlash()`](/docs/api/yii/web/session/index.md#method-getFlash) | Returns a flash message. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getGCProbability"></span>[`getGCProbability()`](/docs/api/yii/web/session/index.md#method-getGCProbability) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getHasSessionId"></span>[`getHasSessionId()`](/docs/api/yii/web/session/index.md#method-getHasSessionId) | Returns a value indicating whether the current request has sent the session ID. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getId"></span>[`getId()`](/docs/api/yii/web/session/index.md#method-getId) | Gets the session ID. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getIsActive"></span>[`getIsActive()`](/docs/api/yii/web/session/index.md#method-getIsActive) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getIterator"></span>[`getIterator()`](/docs/api/yii/web/session/index.md#method-getIterator) | Returns an iterator for traversing the session variables. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getName"></span>[`getName()`](/docs/api/yii/web/session/index.md#method-getName) | Gets the name of the current session. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getSavePath"></span>[`getSavePath()`](/docs/api/yii/web/session/index.md#method-getSavePath) | Gets the current session save path. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getTimeout"></span>[`getTimeout()`](/docs/api/yii/web/session/index.md#method-getTimeout) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getUseCookies"></span>[`getUseCookies()`](/docs/api/yii/web/session/index.md#method-getUseCookies) | Returns the value indicating whether cookies should be used to store session IDs. | [`Session`](/docs/api/yii/web/session/index.md) |
| [`getUseCustomStorage()`](#method-getUseCustomStorage) | Returns a value indicating whether to use custom session storage. | `CacheSession` |
| <span id="method-getUseStrictMode"></span>[`getUseStrictMode()`](/docs/api/yii/web/session/index.md#method-getUseStrictMode) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-getUseTransparentSessionID"></span>[`getUseTransparentSessionID()`](/docs/api/yii/web/session/index.md#method-getUseTransparentSessionID) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-has"></span>[`has()`](/docs/api/yii/web/session/index.md#method-has) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasFlash"></span>[`hasFlash()`](/docs/api/yii/web/session/index.md#method-hasFlash) | Returns a value indicating whether there are flash messages associated with the specified key. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`init()`](#method-init) | Initializes the application component. | `CacheSession` |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-offsetExists"></span>[`offsetExists()`](/docs/api/yii/web/session/index.md#method-offsetExists) | This method is required by the interface [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php). | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-offsetGet"></span>[`offsetGet()`](/docs/api/yii/web/session/index.md#method-offsetGet) | This method is required by the interface [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php). | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-offsetSet"></span>[`offsetSet()`](/docs/api/yii/web/session/index.md#method-offsetSet) | This method is required by the interface [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php). | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-offsetUnset"></span>[`offsetUnset()`](/docs/api/yii/web/session/index.md#method-offsetUnset) | This method is required by the interface [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php). | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-open"></span>[`open()`](/docs/api/yii/web/session/index.md#method-open) | Starts the session. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-regenerateID"></span>[`regenerateID()`](/docs/api/yii/web/session/index.md#method-regenerateID) | Updates the current session ID with a newly generated one. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-remove"></span>[`remove()`](/docs/api/yii/web/session/index.md#method-remove) | Removes a session variable. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-removeAll"></span>[`removeAll()`](/docs/api/yii/web/session/index.md#method-removeAll) | Removes all session variables. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-removeAllFlashes"></span>[`removeAllFlashes()`](/docs/api/yii/web/session/index.md#method-removeAllFlashes) | Removes all flash messages. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-removeFlash"></span>[`removeFlash()`](/docs/api/yii/web/session/index.md#method-removeFlash) | Removes a flash message. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-set"></span>[`set()`](/docs/api/yii/web/session/index.md#method-set) | Adds a session variable. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setCacheLimiter"></span>[`setCacheLimiter()`](/docs/api/yii/web/session/index.md#method-setCacheLimiter) | Set cache limiter | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setCookieParams"></span>[`setCookieParams()`](/docs/api/yii/web/session/index.md#method-setCookieParams) | Sets the session cookie parameters. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setFlash"></span>[`setFlash()`](/docs/api/yii/web/session/index.md#method-setFlash) | Sets a flash message. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setGCProbability"></span>[`setGCProbability()`](/docs/api/yii/web/session/index.md#method-setGCProbability) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setHasSessionId"></span>[`setHasSessionId()`](/docs/api/yii/web/session/index.md#method-setHasSessionId) | Sets the value indicating whether the current request has sent the session ID. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setId"></span>[`setId()`](/docs/api/yii/web/session/index.md#method-setId) | Sets the session ID. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setName"></span>[`setName()`](/docs/api/yii/web/session/index.md#method-setName) | Sets the name for the current session. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setSavePath"></span>[`setSavePath()`](/docs/api/yii/web/session/index.md#method-setSavePath) | Sets the current session save path. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setTimeout"></span>[`setTimeout()`](/docs/api/yii/web/session/index.md#method-setTimeout) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setUseCookies"></span>[`setUseCookies()`](/docs/api/yii/web/session/index.md#method-setUseCookies) | Sets the value indicating whether cookies should be used to store session IDs. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setUseStrictMode"></span>[`setUseStrictMode()`](/docs/api/yii/web/session/index.md#method-setUseStrictMode) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-setUseTransparentSessionID"></span>[`setUseTransparentSessionID()`](/docs/api/yii/web/session/index.md#method-setUseTransparentSessionID) |  | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`calculateKey()`](#method-calculateKey) protected | Generates a unique key used for storing session data in cache. | `CacheSession` |
| <span id="method-freeze"></span>[`freeze()`](/docs/api/yii/web/session/index.md#method-freeze) protected | If session is started it's not possible to edit session ini settings. In PHP7.2+ it throws exception. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-registerSessionHandler"></span>[`registerSessionHandler()`](/docs/api/yii/web/session/index.md#method-registerSessionHandler) protected | Registers session handler. | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-unfreeze"></span>[`unfreeze()`](/docs/api/yii/web/session/index.md#method-unfreeze) protected | Starts session and restores data from temporary variable | [`Session`](/docs/api/yii/web/session/index.md) |
| <span id="method-updateFlashCounters"></span>[`updateFlashCounters()`](/docs/api/yii/web/session/index.md#method-updateFlashCounters) protected | Updates the counters for flash messages and removes outdated flash messages. | [`Session`](/docs/api/yii/web/session/index.md) |

## Property details

### $cache <span id="property-cache"></span>

```php
public yii\caching\CacheInterface|array|string $cache = '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.

## Method details

### getUseCustomStorage() <span id="method-getUseCustomStorage"></span>

```php
public function getUseCustomStorage(): bool
```

Returns a value indicating whether to use custom session storage.

This method overrides the parent implementation and always returns true.

**Returns**

`bool`: Whether to use custom storage.

### init() <span id="method-init"></span>

```php
public function init(): mixed
```

Initializes the application component.

**Returns**

`mixed`

### calculateKey() <span id="method-calculateKey"></span>

```php
protected function calculateKey(string $id): mixed
```

Generates a unique key used for storing session data in cache.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `string` | Session variable name |

**Returns**

`mixed`: A safe cache key associated with the session variable name