I'm trying to change the session backend of Zend_Auth. But couldn't succeed it. In my bootstrap.php ;
$oBackend = new Zend_Cache_Backend_Libmemcached(
array(
'servers' => $servers,
'compression' => false
) );
// configure caching frontend strategy
$oFrontend = new Zend_Cache_Core(
array(
'caching' => true,
'automatic_serialization' => true
) );
// build a caching object
$cache = Zend_Cache::factory( $oFrontend, $oBackend );
$saveHandler = new \Application\Auth\Adapter\Memcached();
$saveHandler->setCacher($cache);
\Zend_Session::setSaveHandler($saveHandler);
It was saving the values Memcache successfully with no problem. I test it ;
$namespace = new Zend_Session_Namespace();
$namespace->name = "Fatih";
In other controllers;
$ns = new Zend_Session_Namespace();
var_dump($ns->name);
It's ok, but I couldn't see Zend_Auth values in Memcache. But if I var_dump($_SESSION)
I can see it like ;
["Zend_Auth"]=> array(1) { ["storage"]=> object(Application_Security_Auth_Storage)#66 (1) { ["_user":protected]=> object(Application_Security_Auth_User)#84 (4) { ["id":protected]=> object(MongoId)#87 (1) { ["$id"]=> string(24) "4fcca6b8c863c79d33000004" } ["username":protected]=> string(5) "admin" ["role":protected]=> string(5) "admin" ["fullname":protected]=> NULL } } }
Here you can see my login method ;
public function login($username, $password)
{
if ($username == "" || $password == "")
return false;
$adapter = new \Application_Security_Auth_Adapter();
$adapter->setIdentity($username);
$adapter->setCredential($password);
$auth = \Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
return $result->isValid();
}