PHP 8.2 Session Data Not Persisting with Redis When Using Multiple Servers
I've spent hours debugging this and This might be a silly question, but I'm attempting to set up Iβm working with an scenario where session data is not persisting across multiple servers when using Redis as the session handler in a PHP 8.2 application... I have a load-balanced setup with two servers, and I configured both to use Redis for session storage. However, when I log in to the application and then switch to the other server, it seems like the session data is lost. Hereβs a snippet of my `php.ini` settings: ```ini session.save_handler = redis session.save_path = "tcp://127.0.0.1:6379" ``` On both servers, I'm using the same Redis instance, and I verified that the Redis server is running correctly. I also tried setting `session.cookie_path` and `session.cookie_domain` to ensure cookies are accessible across subdomains: ```ini session.cookie_path = "/" session.cookie_domain = ".mydomain.com" ``` Despite this, when I start a session on server A and then switch to server B, the session appears to start fresh. I even added some debug logs to check the session ID and found that the session ID changes when switching servers, indicating a new session is being created. I've also tried using the `session_regenerate_id()` function after login to see if that affects it, but the question continues. The Redis session data does seem to be set correctly on the first server, but it's like it's not being recognized or retrieved on the second server. Is there something specific I need to configure in PHP or Redis to ensure sessions continue correctly when using multiple servers? Any insight would be greatly appreciated! This is part of a larger desktop app I'm building. The stack includes Php and several other technologies. I'm on CentOS using the latest version of Php.