PHP session handler using redis not work

PHPphp.iniredis

I was sets 3 servers :

192.168.7.147:6379 <-- redis server
192.168.7.162 <-- web server 1 (using phpredis, with local devdomain jttest.com )
192.168.7.218 <-- web server 1 (using phpredis, with local devdomain jttest.com )

both of 192.168.7.162 and 192.168.7.218 using php.ini configuration exactly like these :

extension=redis.so
session.save_handler = redis
session.save_path = tcp://192.168.7.147:6379

also i have restart apache and redis too after altering these option, of course i can use basic function of redis inside my php code

The problems starts here, i can login on 192.168.7.162 using php standard session call (session_start())
but the session cannot be retrieved on 192.168.7.218 and vice versa, in simple word, redis session not shared.

inside 192.168.7.147 , i was unable to get keys related to the session (session name is PHPREDIS_SESSION), look these result i get from redis-cli

redis 127.0.0.1:6379> keys *
1) "attribute"
2) "test"
redis 127.0.0.1:6379>

one more thing, at 192.168.7.218 php still saves the session using files, not using redis

[root@centos_wira_devel session]# ll
total 8
-rw------- 1 apache apache 792 Feb 26 16:29 sess_1nm86s67o1o696cgopmrc2hq75
-rw------- 1 apache apache 792 Feb 26 16:41 sess_hhmompfoqjh0emoofppg4v5lp2

for information, in my browser, cookie for session (both of 192.168.7.162 and 192.168.7.218) saved as ['PHPREDIS_SESSION'] = hhmompfoqjh0emoofppg4v5lp2

in page phpredis i didnt found any FAQ about this case (https://github.com/phpredis/phpredis), i didn't know where the step i'm missing.

Best Answer

Sessions settings may be altered in other configuration files, except php.ini. This may be confirmed checking the "session" section of phpinfo() output. If the values in column "Local Value" are different of those in column "Master Value", other files must be inspected.
Specifically in Centos, on server 192.168.7.162, it is very probable to have the session.save_handler set to "files", in /etc/httpd/conf.d/php.conf .

Related Topic