When I use following code to auth someone I get an error (only when the information is correct) I have no idea how to solve this :s
PHP Code:
<?
function loginAction()
{
$this->view->message = '';
if ($this->_request->isPost()) {
// collect the data from the user
Zend_Loader::loadClass('Zend_Filter_StripTags');
$f = new Zend_Filter_StripTags();
$username = $f->filter($this->_request->getPost('username'));
$password = $f->filter($this->_request->getPost('password'));
if (empty($username)) {
$this->view->message = 'Please provide a username.';
} else {
// setup Zend_Auth adapter for a database table
Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
$dbAdapter = Zend_Registry::get('dbAdapter');
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('users');
$authAdapter->setIdentityColumn('username');
$authAdapter->setCredentialColumn('password');
// Set the input credential values to authenticate against
$authAdapter->setIdentity($username);
$authAdapter->setCredential($password);
// do the authentication
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
// success: store database row to auth's storage
// system. (Not the password though!)
$data = $authAdapter->getResultRowObject(null,'password');
$auth->getStorage()->write($data);
$this->_redirect('/');
} else {
// failure: clear database row from session
$this->view->message = 'Login failed.';
}
}
}
$this->view->title = "Log in";
$this->render();
}
?>
Code:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Unwritable session.save_path: ' in /home/jasper/public_html/library/Zend/Session.php:217 Stack trace: #0 /home/jasper/public_html/library/Zend/Session.php(360): Zend_Session::setOptions(Array) #1 /home/jasper/public_html/library/Zend/Session/Namespace.php(92): Zend_Session::start(true) #2 /home/jasper/public_html/library/Zend/Auth/Storage/Session.php(85): Zend_Session_Namespace->__construct('Zend_Auth') #3 /home/jasper/public_html/library/Zend/Auth.php(92): Zend_Auth_Storage_Session->__construct() #4 /home/jasper/public_html/library/Zend/Auth.php(121): Zend_Auth->getStorage() #5 /home/jasper/public_html/application/controllers/AuthController.php(51): Zend_Auth->authenticate(Object(Zend_Auth_Adapter_DbTable)) #6 /home/jasper/public_html/library/Zend/Controller/Action.php(501): AuthController->loginAction() #7 /home/jasper/public_html/library/Zend/Controller/Dispatcher/Standard.php(214): Zend_Controller_Action->dispatch('loginAction') #8 /home/jasper/pub in /home/jasper/public_html/library/Zend/Session.php on line 217
So, when I enter a wrong username or password I get an error... when I enter the right details ZF returns an error.
I hope someone can help me out
Thanks,
Jasper