You can modify the php.ini file in the case of:
1, modify the php.ini in the
Copy the Code code 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 normal Access session value is OK.
Do not modify the php.ini file in the case of:
A, dynamically modify the settings in the php.ini.
Copy the Code code as follows:
Ini_set (' Session.save_hander ', ' memcache ');
Ini_set (' Session.save_path ', ' tcp://127.0.0.1:11211 ');
Description: Ini_set () only works on the current PHP page and does not modify the php.ini file itself, nor does it affect other PHP pages.
b, the normal access session value is OK.
Comparison of Memcache and session
The main purpose of Memcache is to alleviate the database pressure and speed up, so it is a stateless data (stateless data: the current data is not tied to a user, such as: Lee saved data, Richard can be taken out, as long as the corresponding key value can be found)
Session data is bound to the user and is therefore a stateful data.
Safety of Memcache
Put the memcache into the intranet and use a firewall to block external access
Suitable for storing data in memcached
The change is frequent, has the instability, does not need the real-time storage, the security low