Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-23-2007, 10:02 AM
jap jap is offline
Junior Member
 
Join Date: Apr 2007
Posts: 23
Default Error when Authing with Zend_Auth *SOLVED*

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-23-2007, 11:08 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 117
Default

you need to give write permission to php to write to whatever session.save_path was set to.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-24-2007, 10:32 AM
jap jap is offline
Junior Member
 
Join Date: Apr 2007
Posts: 23
Default

Quote:
Originally Posted by SpotSec View Post
you need to give write permission to php to write to whatever session.save_path was set to.
I've edited my php.ini and set the directory to /tmp

But I wasn't able to reset my server yet due to the ports that are blocked from the network i'm on atm.

Thanks for your reply, I'll let you know when I've found the solution
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-24-2007, 03:09 PM
jap jap is offline
Junior Member
 
Join Date: Apr 2007
Posts: 23
Default

Quote:
Originally Posted by jap View Post
I've edited my php.ini and set the directory to /tmp

But I wasn't able to reset my server yet due to the ports that are blocked from the network i'm on atm.

Thanks for your reply, I'll let you know when I've found the solution
PROBLEM SOLVED

(changed the save_path to /tmp)

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-30-2007, 10:13 PM
Junior Member
 
Join Date: Jun 2007
Location: Barcelona
Posts: 8
Default <? short tags

Little advice: do not use the short tags "<?".
Zend Frameworks' manual discourages it. If you'll need to export your application to a server which does not support them, you'll have to modify all your pages...
__________________
------------------
Loris Candylaftis

Last edited by loloziberlo : 06-30-2007 at 10:21 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:03 AM.