Memcache Storing PHP session
1. Modify the configuration file and set the global settings in php.ini:
Session.save_handler = Memcachesession.save_path = "tcp://127.0.0.1:11211"
Or a. htaccess in a directory:
Php_value Session.save_handler "Memcache" Php_value session.save_path "tcp://127.0.0.1:11211"
Or in one application:
Ini_set ("Session.save_handler", "memcache"); Ini_set ("Session.save_path", "tcp://127.0.0.1:11211");?
Use multiple memcached servers separated by commas "," and, as described in the memcache::addserver () documentation, can take additional parameters "persistent", "weight", "timeout", "Retry_ Interval "And so on, like this:" Tcp://host1:port1?persistent=1&weight=2,tcp://host2:port2 ".
5. Use Memcache for session storage in the program, and test it with an example:
Connect (' 127.0.0.1 ', 11211); $var = $memcache _obj->get (session_id ()); Echo $var;? >
will have to see
Array ([Joo] = hello~) joo|s:6: "hello~";
This output proves that the session is working properly.
Using Memcache to store sessions can be much faster than files when reading and writing, and it is convenient to have multiple servers sharing sessions, which are configured to use the same set of memcached servers, reducing the additional effort.
The disadvantage is that the session data are stored in memory, the persistence of the lack of, but the session data is not a big problem.
1/F Jimmyyem 2012-02-15
I really win the following test, I installed the memcache, not memcached, I am in php.ini and procedures to change 2 kinds have tried, found not yet
Give me a hint