PHP saves the session to the memcache server, sessionmemcache. PHP saves the session to the memcache server. sessionmemcache this article describes how PHP saves the session to the memcache server. For your reference, refer to the method for saving session to memcache server in PHP, sessionmemcache.
This example describes how PHP saves a session to the memcache server. We will share this with you for your reference. The details are as follows:
The traditional session is written to the server file. you can see in php. ini that the list is as follows:
Session. save_handler = filessession. save_path = "sess save path"
However, if there are many website users, session access will inevitably affect the website speed. Because the file reading speed is very low.
As we all know, memcache, as a memory cache server, uses a hash algorithm to read data in the form of key-> value, which is much faster than reading files.
The configuration for saving the session to the memcache server is as follows:
Method 1:
Open the php. ini file and modify the following two parameters:
Session. save_handler = memcachesession. save_path = "tcp: // Mem server 1: port number, tcp: // Mem Server 2: port number ..."
Method 2:
Use the ini_set function in the php file for configuration. this method solves the php configuration problem of the shared server.
<? Php .... ini_set ("session. save_handler "," memcache "); ini_set (" session. save_path "," tcp: // Mem server 1: port number, tcp: // Mem Server 2: port number... ");...?>
Restart the Web server!
In this case, the session will not be saved as a file, but will be saved to the Memcache server. the key to be saved is session_id.
Telnet to the memcache server for get View
Telnet memcache server port number