У меня была эта проблема раньше, когда данные сеанса были больше, чем барьер Memcache в 1 МБ.Я решил это путем сжатия данных сеанса до их сохранения в Memcache.
Вот код, который я использую:
<?php
class SessionHandler {
public $lifeTime;
public function __construct() {
$this->lifeTime = intval(ini_get("session.gc_maxlifetime"));
session_set_cookie_params(0,"/",".domain.com",false,true);
session_name("SITESESSION");
session_set_save_handler(array (&$this,"open"),array (&$this,"close"),array (&$this,"read"),array (&$this,"write"),array (&$this,"destroy"),array (&$this,"gc"));
session_start();
}
public function open($savePath,$sessionName) {
return true;
}
public function close() {
return true;
}
public function read($sessionID) {
# The default miss for MC is (bool) false, so return it
return MC::get("userSession_{$sessionID}");
}
public function write($sessionID,$data) {
# This is called upon script termination or when session_write_close() is called, which ever is first.
return MC::set("userSession_{$sessionID}",$data,$this->lifeTime,true); # The last true sets it as compressed.
}
public function destroy($sessionID) {
# Called when a user logs out...
return MC::delete("userSession_{$sessionID}");
}
public function gc($maxlifetime) {
# The MC keys expire on their own, no need to do anything here.
return true;
}
}
?>