search
Homephp教程php手册php将session放入memcached的设置方法

可以修改php.ini文件的情况下:

1、修改php.ini中的

 

复制代码 代码如下:


session.save_hander = memcache;
session.save_path = "tcp://host:端口号";//例如:session.save_path = "tcp://127.0.0.1:11211";

2、正常存取session的值就OK了。

不可以修改php.ini文件的情况下:

 a、动态修改php.ini中的设置。

 

复制代码 代码如下:


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


说明:ini_set()只对当前php页面有效,并且不会去修改php.ini文件本身,也不会影响其他php页面。

 b、正常存取session的值就OK了。

Memcache和Session的比较
 memcache的主要目的是缓解数据库压力并提速,因此它是一种无状态的数据(无状态数据:当前数据并不和某个用户绑定,比如:Lee存的数据,Richard可以取出来,只要知道对应的key值就可以)
 session数据是和用户绑定的,因此是一种有状态的数据。

Memcache的安全性
将memcache放入内网中,用防火墙去阻止外部访问

适合存入Memcached中的数据
变化频繁的,具有不稳定性的,不需要实时入库的,安全性较低的

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools