Lets start with, this is working for me and I am posting this because of the time it took me to find the little information I could about Zend_Session::setSaveHandler utilizing memcache.

We are going to make the assumption you have memcache loaded and working; cause I don’t feel like explaining the howto install memcache. We are also going to assume you know a bit about ZF, mainly because I suck at explaining the is, why, and where of programming.

  1. Create a customer session handler that implements Zend_Session_SaveHandler_Interface
  2. In your boot strap load your session handler class, Zend_Loader::loadClass(’Your_SessionHandler_Class’)
  3. In your boot strap Zend_Session::setSaveHandler(new Your_SessionHandler_Class($_cache)); .. more about the $cache var in a sec
  4. Zend_Session::start(); and your good to go

Steps By Example:

Step 1.

class Lib_Custom_Helper_SessionHandler implements Zend_Session_SaveHandler_Interface {
private $maxlifetime = 3600;
public $cache = '';
public function __construct($cacheHandler) {
$this->cache = $cacheHandler;
}
public function open($save_path, $name) {
return true;
}
public function close() {
return true;
}
public function read($id) {
if(!($data = $this->cache->load($id))) {
return '';
}
else {
return $data;
}
}
public function write($id, $sessionData) {
$this->cache->save($sessionData, $id, array(), $this->maxlifetime);
return true;
}
public function destroy($id) {
$this->cache->remove($id);
return true;
}
public function gc($notusedformemcache) {
return true;
}
}

Step 2:
Zend_Loader::loadClass('Lib_Custom_Helper_SessionHandler');

Step 3:
Ok, so after some reading I saw a few ways to plug memcache into my session handler. I opted for this option because I was already establishing config variables and connection information for Zend_Cache, utilizing memcache, so instead of passing the connection info again, I am passing my sessionhandler my cache handle which feeds directly into memcache as it is. So before my session setup I run
$_cache = Zend_Cache::factory('Core', 'Memcached', $frontendOptions, $backendOptions);
and then
Zend_Session::setSaveHandler(new Lib_Custom_Helper_SessionHandler($_cache));

Step 4:
Zend_Session::start();

And there you have it… my sessions are now stored into memcache via my already running cache handler… Hope this helps someone out there… took me forever to find info on specific howto’s…