Php puts session in memcached setting method
This article mainly introduces how to set the php session to memcached. For more information, see
You can modify the php. ini file:
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