php自定义session用memcache来存储session会话

代码语言:php

所属分类:会话

代码描述:php自定义session用memcache来存储session会话

代码标签: memcache 存储 session 会话

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<?php
class MemcacheSession implements SessionHandlerInterface {
    private $link;
    private $lifetime;
    public function open($savePath, $session_name) {
        $this->lifetime = get_cfg_var('session.gc_maxlifetime');
        $this->link = new \Memcache();
        $this->link->connect("127.0.0.1", 11211);
        if ($this->link) {
            return true;
        }
        return false;
    }
    public function close() {
        $this->link->close();
        return true;
    }
    public function read($session_id) {
        return $this->link->get($session_id);

    }
    public function write($session.........完整代码请登录后点击上方下载按钮下载查看

网友评论0