Memcache stores phpsession1. modify the configuration file and set session. save_handler = memcachesession. save_path = "tcp: // 127.0.0.1: 11211" globally in php. ini.
1. modify the configuration file and set it globally in php. ini:
session.save_handler = memcachesession.save_path = "tcp://127.0.0.1:11211"
Or. htaccess in a directory:
php_value session.save_handler "memcache"php_value session.save_path "tcp://127.0.0.1:11211"
Or in an application:
ini_set("session.save_handler", "memcache");ini_set("session.save_path", "tcp://127.0.0.1:11211");?
Multiple memcached servers are separated by commas (,), which are the same as those described in the Memcache: addServer () document, you can include additional parameters such as "persistent", "weight", "timeout", and "retry_interval". for example, "tcp: // host1: port1? Persistent = 1 & weight = 2, tcp: // host2: port2 ".
5. use memcache in the program for session storage. use an example to test it:
connect('127.0.0.1', 11211);$var = $memcache_obj->get(session_id());echo $var;?>You will see
Array ( [joo] => hello~ ) joo|s:6:"hello~";
This output proves that the session works normally.
Using memcache to store sessions is much faster in reading and writing than when using files, and it is more convenient when multiple servers need to share sessions, you can configure these servers to use the same group of memcached servers, reducing the additional workload.
The disadvantage is that session data is stored in memory, which lacks persistence, but it is not a big problem for session data.
Jimmyyem on the first floor 2012-02-15 I actually tested it under win. I installed memcache, not memcached. I tried it in php. ini and in the program, but I found that I still cannot.
Give me some advice