views:

47

answers:

1

Tue, 23 Sep 2008 05:44:40 -0700

i want to create multiple instances of zend_auth class

as i have two modules

Admin Front

wats happening is when i login into admin it automatically get logins into front or vice-versa.

so wat i want is the i can work on both modules separately after simultaneous authentication.

+1  A: 

Zend_Auth is a singleton, so you can't. What I do is to use Zend_Acl ensure that only users with a role of "admin" can get at the administration stuff.

To create a second Auth object, in principle, you could derive Zend_Auth to App_Auth and use a different session namespace. I've never tried this, but my starting code would look like this:

class App_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) {
            /**
             * @see Zend_Auth_Storage_Session
             */
            require_once 'Zend/Auth/Storage/Session.php';
            $this->setStorage(new Zend_Auth_Storage_Session('App_Auth'));
        }

        return $this->_storage;
    }
}

It's possible that you have to override more.

Rob Allen