Home >Backend Development >PHP Tutorial >PHP setting method to put session into memcached_PHP tutorial

PHP setting method to put session into memcached_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:24:55750browse

When the php.ini file can be modified:

1. Modify

in php.ini

Copy code 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. It is OK to access the session value normally.

When the php.ini file cannot be modified:

a. Dynamically modify the settings in php.ini.

Copy code 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 will not modify the php.ini file itself , it will not affect other php pages.

b. Normal access to the session value is OK.

Comparison between Memcache and Session
The main purpose of memcache is to relieve database pressure and speed up, so it is a kind of stateless data (stateless data: the current data is not bound to a certain user, such as: Lee Richard can take out the stored data, as long as he knows the corresponding key value)
Session data is bound to the user, so it is a stateful data.

Security of Memcache
Put memcache into the intranet and use a firewall to block external access

Suitable for data stored in Memcached
Data that changes frequently, is unstable, does not need to be stored in real time, and has low security

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825256.htmlTechArticleIf you can modify the php.ini file: 1. Modify the copy code in php.ini as follows: session .save_hander = memcache; session.save_path = "tcp://host:port number";//For example: se...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn