Skip to content

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

License

Notifications You must be signed in to change notification settings

klsoft-web/yii3-cache-session-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

YII3-CACHE-SESSION-HANDLER

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

See also:

  • YII3-CACHE-REDIS - The package provides the Redis handler and implements the PSR-16 cache using the Redis PHP extension

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']
                ])
            )
        ]
    ],
];

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages