This article mainly introduces how Laravel uses Redis to share Session. This article introduces you to it in very detail and has reference value. Friends who need it can refer to it. I hope it can help everyone.
1. When the number of visits to the system increases, using Redis to save the Session can improve the performance of the system, and also facilitates the sharing of the Session when multiple machines are under load
1. Open config/database.php. Add session connection in redis
##
'session' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => 10, ],
'connection' => 'session',
SESSION_DRIVER=redis
2. Redis access configuration. In order to use other servers to access redis, you need to configure redis remote access
1 .Open /etc/redis.conf and modify the bind information. For example, the current server LAN IP is 10.0.0.2bind 127.0.0.1 10.0.0.2
protected-mode no
service redis-server reload
iptables -I INPUT -s 10.0.0.2 -p tcp -m state --state NEW -m tcp --dport 6379 - j ACCEPT
REDIS_HOST=10.0.0.2
think how to use memcache to share session data in PHP with multiple domain names
The above is the detailed content of Laravel uses Redis to share Session. For more information, please follow other related articles on the PHP Chinese website!