Zend_Auth はシングルトン パターンを実装しているため、このクラスのインスタンスは 1 つしか存在できません。
現在の ID が管理者かユーザーかを区別するには、 isAdmin-Flag を使用するか、Zend_Acl_Role_Interfaceを実装することをお勧めします。
アプリケーションで同時に 2 つの Auth-Session (ユーザー用に 1 つ、管理者用に 1 つ) を持つことが本当に必要な場合は、Zend_Auth クラスを拡張して「コピー」し、セッション ストレージを調整することができます。
<?php
class Zend_Auth_Admin extends Zend_Auth
{
/**
* Returns the persistent storage handler
*
* Session storage is used by default unless a different storage adapter has been set.
*
* @return Zend_Auth_Storage_Interface
*/
public function getStorage()
{
if (null === $this->_storage) {
$namespace = 'Zend_Auth_Admin'; // default is 'Zend_Auth'
/**
* @see Zend_Auth_Storage_Session
*/
require_once 'Zend/Auth/Storage/Session.php';
$this->setStorage(new Zend_Auth_Storage_Session($namespace));
}
return $this->_storage;
}
}
したがって、セッション処理に 2 つの異なる Auth オブジェクトを使用できます
Zend_Auth::getInstance(); // instance for users
Zend_Auth_Admin::getInstance(); // instance for admins