Php puts the session into the memcached setting method. Php. in the case of INI files: 1. modify php. the copy code in ini is as follows: session. save_handermemcache; session. save_pathtcp: host: port number; for example, se can modify php. in the case of INI files:
1. modify
The code is as follows:
Session. save_hander = memcache;
Session. save_path = "tcp: // host: port number"; // for example, session. save_path = "tcp: // 127.0.0.1: 11211 ";
2. the value of the normal access session is OK.
You cannot modify the php. ini file:
A. modify the settings in php. ini dynamically.
The code is as follows:
Ini_set ('session. save_hander ', 'memcache ');
Ini_set ('session. save_path ', 'tcp: // 127.0.0.1: 11211 ');
Note: ini_set () is only valid for the current php page and does not modify the php. ini file itself, nor affect other php pages.
B. The value of the normal access session is OK.
Comparison between Memcache and Session
Memcache is mainly designed to relieve database pressure and speed up, so it is a stateless data (stateless data: the current data is not bound to a user, such as Lee stored data, richard can obtain the corresponding key value)
Session data is bound to users, so it is stateful data.
Security of Memcache
Put memcache into the intranet and use the firewall to block external access
Suitable for storing data in Memcached
Frequent and unstable changes, without the need to store data in real time, with low security
Example 1: modify the code in php. ini as follows: session. save_hander = memcache; session. save_path = "tcp: // host: port number"; // example: se...