CloudFlare, Load Balancer, and Yii 2?

So we’re having an issue with using CloudFlare, a load balancer, and Yii 2. It looks like Yii 2 uses an ip-based session persistence, but with CloudFlare + the load balancer, it keeps returning different IPs so users don’t stay logged in. Is there any work around to this or has anyone seen this issue and fixed it?

Likely that’s because of sessions. These are written into file system and if you have multiple servers that means sessions are separated. Try moving your sessions into Redis.

Is there a good tutorial for doing this for Yii 2? Not really a devops person.

https://www.yiiframework.com/extension/yiisoft/yii2-redis/doc/guide/2.0/en/topics-session