I'm trying to create a custom Zend_Session save handler that works with memcache. The code basically goes like this:
<?php class Custom_Session_SaveHandler_Memcached implements Zend_Session_SaveHandler_Interface { private $cache = null; public function __construct($cache) { $this->cache = $cache; } public function read ($id) { if(!($data = $this->cache->load($id))) { return ''; } else { return $data; } } public function write ($id, $data) { $this->cache->save($data, $id); return true; } public function open ($save_path, $name) { return true; } public function close () { return true; } public function destroy ($id) { } // not used for memcache public function gc ($maxlifetime) { return true; } } This works perfectly fine, session information is saved to memcache using the SID. The problem I'm having is that I have some legacy code which won't be utilizing Zend Framework and also uses memcache to save session information. I'd like to be able to share session information between the legacy code and my Zend App, but I've hit a wall because there appears to be a conflict between Zend_Session::setSaveHandler(memcache) and using the ini directive "session.save_handler=memcache". After debugging the issue, basically watching the state of my memcache values when transitioning from legacy code to my Zend app, it appears that the session information gets cleared between requests, so that any values written to memcache by the legacy app save handler won't transition into the Zend app and viceversa. Besides using ini settings in the Zend app, does anyone have any advice as to why this is happening? - jake