klsoft/yii3-cache-session-handler

The package implements the SessionHandlerInterface using the PSR-16 cache for storage

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/klsoft/yii3-cache-session-handler

1.0.0 2026-02-16 13:38 UTC

This package is auto-updated.

Last update: 2026-02-16 13:39:22 UTC


README

The package implements the SessionHandlerInterface using the PSR-16 cache for storage.

See also:

Requirement

  • PHP 8.1 or higher.

Installation

composer require klsoft/yii3-cache-session-handler

How to use

Configure the SessionInterface.

Example:

use Yiisoft\Session\SessionInterface;
use Yiisoft\Session\Session;
use Klsoft\Yii3CacheSessionHandler\SessionHandler;
use Yiisoft\Cache\CacheInterface;
use Yiisoft\Cache\Cache;
use Klsoft\Yii3CacheRedis\RedisCache;

return [
    // ...
    SessionInterface::class => [
        'class' => Session::class,
        '__construct()' => [
            'options' => $params['session']['options'] ?? [],
            'handler' => new SessionHandler(
                new RedisCache(
                    new Redis([
                        'host' => $params['redisHost'],
                        'port' => $params['redisPort'],
                        'database' => $params['redisDatabaseSession']
                    ])
                )
            )
        ]
    ],
    CacheInterface::class => [
        'class' => Cache::class,
        '__construct()' => [
            'handler' => new RedisCache(
                new Redis([
                    'host' => $params['redisHost'],
                    'port' => $params['redisPort'],
                    'database' => $params['redisDatabaseCache']
                ])
            )
        ]
    ],
];