php puts session into the memcached setup method

  • 2021-01-03 20:51:17
  • OfStack

php. ini file can be modified in case:

1. Modify php.ini


session.save_hander = memcache;
session.save_path = "tcp://host: The port number ";// Such as: session.save_path = "tcp://127.0.0.1:11211";

2. Normal access to the session value is OK.

php. ini file cannot be modified:

a, dynamically modify the Settings in ES21en. ini.


ini_set('session.save_hander', 'memcache');
ini_set('session.save_path', 'tcp://127.0.0.1:11211');

Note: ini_set() only works on the current php page and does not modify the php.ini file itself, nor does it affect other php pages.

Normal access to the value of session is OK.

Comparison of Memcache and Session
The main purpose of memcache is to alleviate database pressure and speed up, so it is a kind of stateless data (stateless data: the current data is not bound to a user, for example: Lee stored data, Richard can be retrieved, as long as the corresponding key value is known).
session data is bound to the user and is therefore a form of stateful data.

The security of Memcache
Put memcache on the Intranet and use a firewall to block external access

Suitable for data stored in Memcached
Frequently changing, unstable, not requiring real-time storage, and of low security


Related articles: