Laravel all sessions IDs with Redis driver

前端 未结 1 1293
失恋的感觉
失恋的感觉 2021-01-22 03:09

In my application I want to allow for some user, to be able to sign out all other users except him/her. I have done this functionality, well, when the Session driver was set to

相关标签:
1条回答
  • 2021-01-22 03:40

    Keep your session and cache separate.

    In the file \config\database.php

    You can set many redis connections, by default there is a "default" but you can add more to it

    let's say you created 'session-connection' and 'cache-connection'

    now you need to make use of it

    go to file 'config\session.php'

    and set it to 'connection' => 'session-connection',

    then go to file config\cache.php

    and set it to

        'redis' => [
            'driver'     => 'redis',
            'connection' => 'cache-connection',
        ],
    

    and now you can get your redis session records.

    use Illuminate\Support\Facades\Redis;
    \Log::debug( Redis::connection('session-connection')->keys('*') );
    
    0 讨论(0)
提交回复
热议问题