I have configured PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27)
on Centos7.0 to use memcached for session handling.
[Session]
; Handler used to store/retrieve data.
; http://php.net/session.save-handler
session.save_handler = memcached
session.save_path = "tcp://127.0.0.1:11211"
According to phpinfo()
, the Local Values for session.save_handler
& session.save_path
are different to the Master values.
The Master Values are as indicated in the php.ini file.
I can’t see these Local Values being set in .htaccess, under /etc/httpd or in the PHP code base.
Is there somewhere else that they are likely to come from or are these fallback values that might indicate a problem with my memcached
configuration. If so, how does one fix this?
I can verify that memcached
is working by using an example like this one from Digital Ocean and seeing the data in a telnet session.
<?php
$mem = new Memcached();
$mem->addServer("127.0.0.1", 11211);
$result = $mem->get("blah");
if ($result) {
echo $result;
} else {
echo "No matching key found. I'll add that now!";
$mem->set("blah", "I am data! I am held in memcached!") or die("Couldn't save anything to memcached...");
}
?>
I have also tried adding these lines to a .htaccess file.
php_flag session.save_handler "memcached"
php_flag session.save_path "127.0.0.1:11211"
But the values appeared zeroed out.
Best Answer
The Centos7.0 PHP package comes with an additional Apache Confuration file that is confusingly called
php.ini
. This contains statements that override thesession.save_handler
andsession.save_path
variables.