session是php中一个服务器端超级全局变量而memcache是缓存应用,下面我来把它们整合起来把session存放在memcache中,下面我们一起来看如何实现的吧。
1.首先安装memcached或者memcache软件
参考:wamp 安装 memcache/memcached详细说明
2.安装php_memcache.dll扩展
3.设置session保存在memcached
方法一:
修改php.ini文件
session.save_handler = memcache session.save_path = "tcp://127.0.0.1:11211"
方法二:
程序中动态设置
ini_set("session.save_handler", "memcache"); ini_set("session.save_path", "tcp://127.0.0.1:11211");
测试程序
1.session.php
2.test.php
<?php // memcache test code $memcache = new Memcache; //创建一个memcache对象 $memcache->connect('127.0.0.1', 11211) or die("Could not connect"); //连接Memcached服务器 print_r($memcache->get('5d3d79d7500f5836033e9019b3eefc6f')); //username|s:9:"phpff.com"; ?>
文章链接:
随便收藏,请保留本文地址!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

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.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
