Home >Backend Development >PHP Tutorial >Use memcache to save session

Use memcache to save session

藏色散人
藏色散人forward
2019-04-23 15:12:213175browse

By default, the session is saved in the form of a file on the server side. When we encounter large traffic and high concurrency, we will cluster the web server. Then session sharing between different servers will become a problem.

Using memcache to save the session can improve the access speed of the session. At the same time, the problem of session sharing can be solved.

It is very easy to use memcache to save session in php language.

Use php code to complete the use of memcache to save the session

ini_set("session.save_handler", "memcache");
ini_set("session.save_path", "tcp://127.0.0.1:11211");
session_start();

Global settings in php.ini

Modify php.ini

session.save_handler = memcache  
session.save_path = "tcp://127.0.0.1:11211"

The above is the detailed content of Use memcache to save session. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:hcoder.net. If there is any infringement, please contact admin@php.cn delete