As we all know, the traditional session data is stored in the file, so that, to a certain extent, reduce the speed.
Before we implement the problem, the php.ini should be configured as follows:
Session.save_handler = memcache //Specify to save data using memcached
Session.save_path = "tcp://127.0.0.1:11211" //connection to specify session data
Sometimes you can also use Ini_set ("key", "key value") to set the php.ini operation configuration.
When we want to take out, the key should be the session ID, not the name.
<?phpsession_start (); $_session[' name ']= "xuning"; $name =$_session[' name '];echo $name. ' <br/> '; echo session_id ();? >
Similarly, it can be used to save object data.
While it is said that Memcached has a great advantage in terms of speed, it is absolutely not recommended to save important information because the data is completely lost after shutting down the service.
Furthermore, data is not bound to any user and can be extracted directly from the key name. The session must be assigned to the user.
It is forbidden to use memcached in public network, if used, to join the firewall.
Memcached methods and security issues for saving sesion data