Php puts session in memcached setting method

Source: Internet
Author: User
Tags php session

Php puts session in memcached setting method

This article mainly introduces how to set the php session to memcached. For more information, see

You can modify the php. ini file:

 

1. Modify

 

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. The value of the normal access session is OK.

 

You cannot modify the php. ini file:

 

A. Modify the settings in php. ini dynamically.

 

 

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 does not modify the php. ini file itself, nor affect other php pages.

 

B. The value of the normal access session is OK.

 

Comparison between Memcache and Session

Memcache is mainly designed to relieve database pressure and speed up, so it is a stateless data (stateless data: the current data is not bound to a user, such as Lee stored data, richard can obtain the corresponding key value)

Session data is bound to users, so it is stateful data.

 

Security of Memcache

Put memcache into the Intranet and use the firewall to Block external access

 

Suitable for storing data in Memcached

Frequent and unstable changes, without the need to store data in real time, with low security

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.