PHP sessions not being saved in memcache

纵然是瞬间 提交于 2019-12-03 03:19:44

OK, we managed to figure out the issue.

First, we created a simple page that spit out phpinfo(). Note that it is important that you run this thru the web server - running php -i DOES NOT include any overrides that apache may add.

Under the session section, the output lists all the directives, and a "Local Value" and a "Master Value".

The local values had:

session.save_handler    files
session.save_path   /var/lib/php/session

while the master values had:

session.save_handler    memcache
session.save_path   tcp://<endpoint>:11211

It turns out that there's an override installed by default in /etc/httpd/conf.d/php.conf that specifies the files. This appears to be a Redhat/CentOS/Fedora thing.

Removing those values from php.conf fixed the problem.

user3733902

Both of the major memcache PHP PECL extensions have session handlers. Either will require you to install a PECL module before use.

The Memcache PECL extension session handler is enabled with the following in php.ini:

session.save_handler = "memcache"
session.save_path = "tcp://memcacheServerAddressHere:11211?persistent=1&weight=2&timeout=2&retry_interval=10"

The Memcached PECL extension session handler is enabled with the following in php.ini:

session.save_handler = "memcached"
session.save_path = "memcacheServerAddressHere:11211"

Note that the Memcache extension appears to allow more configuration of the Memcache environment.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!