Hi!
I have a problem and i need some help. :)
I use Zend_Auth i my application. The basic of using Zend_Auth Acrabat
Zend_Auth tutorial.
In my IndexController class is the next code:
public function preDispatch() {
$auth = Zend_Auth::getInstance();
if(!$auth->hasIdentity()) {
$this->_redirect('auth/login');
}
}
Because everybody have to login.
I use session storage with 'auth' namespace.
But the code stop the next error message:
Fatal error: Cannot use object of type stdClass as array in
/var/www/saycms/zend_framework/Zend/Session/Abstract.php on line 92
This code is part of Zend Framework.
I search what is the problem several hours, but i don't know what is
the problem. I understand what means the message, but i don't know
why.
I did this:
1, i changed the session namespace to nothing (default is "storage")
2, i drop the code (preDispatch() method) -> the code is working fine,
but i can't protect my application. :(
3, I followed the error (var_dump() and die() -> it was funny... and
long time...) and the result:
the problem is in the Zend_Auth::hasIdentity() method
public function hasIdentity()
{
return !$this->getStorage()->isEmpty();
}
Here is the problem is in the isEmpty() method. The method part of
Zend_Auth_Storage_Session (Zend_Auth_Storage_Session is implement
Zend_Auth_Storage_Interface) class:
public function isEmpty()
{
return !isset($this->_session->{$this->_member});
}
if i run the code this:
public function isEmpty()
{
var_dump($this->_session);
echo "<br>";
var_dump($this->_member);
die();
return !isset($this->_session->{$this->_member});
}
the result is like this:
object(Zend_Session_Namespace)#36 (1) { ["_namespace:protected"]=>
string(9) "Zend_Auth" }
string(7) "storage"
I searched the google lot of without results. Anybody hasn't this
problem and i can't resolv this problem.
Thank's the help.
András
ps.: sorry my english
--
- -
-- Csanyi Andras --
http://sayusi.hu -- Sayusi Ando
-- "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell