The following is a simple PHP project distributed deployment, a session of the synchronization scheme, using Memcache to store the session. and summed up three kinds of configuration methods, need friends can refer to the next
1, directly modify the php.ini configuration file code as follows: Session.save_handler = memcache//Set session storage mode for memcache Memcache.hash_ Strategy = "consistent"//set Memcache hash algorithm Session.save_path = "tcp://127.0.0.100:11211"//Set session storage location, Multiple memcache are separated by commas, such as:tcp://127.0.0.1:11211,tcp://127.0.0.1:12000 2, using the. htaccess file configuration code below in the directory: PHP_ Value Session.save_handler "Memcache" php_value Session.save_path "tcp://127.0.0.1:11211" Description: This is only for Apache, the current use of nginx more, also do not recommend this approach. 3, modify the configuration in the project's PHP file copy code code as follows: Ini_set ("Session.save_handler", "Memcache"); Ini_set (" Session.save_path "," tcp://127.0.0.100:11211 "); 4, test example code as follows://test session read is normal session_start (); $_session[' username '] = "jb51.net"; Echo session_id (); //read from Memcache session $m = new Memcache (); $m->connect (' localhost ', 11211); //or so //$mem->addserver ("127.0.0.1", 11211) or Die ("Can" t add Memcache server 127.0. 0.1:12000 "); //session_id Access data //Ben //$session = $m->get (session_id ()); session_id:d527b6f983bd5e941f9fff318a31206b //Another server, known session id $session = $m->get (" d527b6f983bd5e941f9fff318a31206b "); echo $session." <br/> "; Will get the data: username|s:16: "Pandao"; the corresponding value can be obtained by parsing the echo session_id (). <br/> "; exit; above just a few simple instructions, in fact, said Han off, generally speaking, do distributed, that must have server permissions, so recommend the first."