Пример #1
0
 public static function init()
 {
     if (!array_key_exists("session_lifetime", C())) {
         self::$lifetime = ini_get('session.gc_maxlifetime');
     }
     self::$time = time();
     self::$handler = new Memcache();
     $pro = C("memcache_prot") ? C("memcache_prot") : 11211;
     self::$handler->connect(C("memcache_host"), intval($pro));
     if (!self::$handler) {
         throw new Exception("Session驱动连接失败");
     }
     self::start();
 }
 /**
 +----------------------------------------------------------
 * 关闭Session 
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 */
 public function close()
 {
     $this->gc(ini_get('session.gc_maxlifetime'));
     self::$mHandle->close();
     self::$mHandle = null;
     self::$staticCache = null;
     return true;
 }
Пример #3
0
<?php

include 'SessionMemcache.class.php';
SessionMemcache::$options = array('host' => 'localhost', 'port' => 11211, 'expired' => 86400);
$mobj = new SessionMemcache();
$mobj->execute();
session_start();
echo 'before:' . $_SESSION['ok'];
$_SESSION['ok'] = time();
echo 'after:' . $_SESSION['ok'];