Hi
I'm using a Storage_Cookie like
http://metaversedeveloper.com/2009/01/03/logging-in-users-via-zend_auth-without-sessions-in-php-zend-framework/ I only add json_encode/decode
to manage the not scalar data.
I've had trouble with the logout method because the
$auth->hasIdentity() was still true after the logout action.
I end up with this code and it works but it seems to me just a little odd
public function clear()
{
if (!setcookie($this->_cookieName,
false, // clears the cookie
time()-$this->_expire,
$this->getBasedir())) {
throw new Zend_Auth_Storage_Exception('Failed to clear cookie');
}
/* odd ! with a DEBUG session it is set with the user email !!!!!!!
used as identity
*/
unset($_SESSION[$this->_cookieName]);
unset($_COOKIE[$this->_cookieName]);
}
In my bootstrap
protected function _initAuth()
{
$auth = Zend_Auth::getInstance();
if(null !== W_Cookie::get('wh')){
$auth->setStorage(new W_Auth_Storage_Cookie(md5('ayn'), md5('ayn')));
}
else{
$auth->setStorage(new Zend_Auth_Storage_Session(md5('ayn')));
}
Zend_Registry::set('auth', $auth);
}
In my controller
LOGIN
W_Cookie::deleteCookie('wh');
if(!empty($remember)){
W_Cookie::setCookie('wh',md5(time()));
$this->auth->setStorage(new W_Auth_Storage_Cookie(md5('ayn'), md5('ayn')));
}
$this->auth->getStorage()->write($data);
LOGOUT
W_Cookie::deleteCookie('wh');
$this->auth->clearIdentity();
$this->_helper->redirector('index','index','default');
Does anyone know why ?
Thanks in advance
Bye