T
T
time_is_always_against_us2019-08-06 01:14:56
Laravel
time_is_always_against_us, 2019-08-06 01:14:56

How to hang session on redis in laravel?

Was guided by the official manual, but did not want to work. Google didn't help either.
1. Installed Redis (predis/predis). Works correctly with Laravel, facade is available.
2. Set up config/database.php:

'redis' => [
        'client' => env('REDIS_CLIENT', 'phpredis'),
        'options' => [
            'cluster' => env('REDIS_CLUSTER', 'predis'),
            'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
        ],
        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_DB', 0),
        ],
        'cache' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => env('REDIS_CACHE_DB', 1),
        ],
/* Насколько понял должно быть достаточно default подключения, 
но для теста, по нагугленным мануалам, сделал отдельное */
        'session' => [ 
          'host' => env('REDIS_HOST', '127.0.0.1'),
          'password' => env('REDIS_PASSWORD', null),
          'port' => env('REDIS_PORT', 6379),
          'database' => 1,
        ],
    ],

3. Further in config/session.php:
'driver' => env('SESSION_DRIVER', 'redis'),
'connection' => env('SESSION_CONNECTION', 'session'), 
/* Вместо default здесь session. */

4. I check through authorization, but there is still no session in Redis. I don't see anything through Redis-cli either.
Please tell me what I forgot to do or did wrong. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Barsukov, 2019-08-06
@time_is_always_against_us

In the .env file in the line
Specify
Also make sure that you read .env

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question