View Single Post
  #1 (permalink)  
Old 04-25-2008, 12:13 AM
cc96ai cc96ai is offline
Junior Member
 
Join Date: Dec 2007
Posts: 4
Default how to set timeout in zend Auth

how could I add session time in auth ? like session only valid for 5 min
Quote:
// setup Zend_Auth adapter for a database table
Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable' );
$db = Zend_Registry::get('db');
$authAdapter = new Zend_Auth_Adapter_DbTable($db);
$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.';
}
I try the follow, but it will expire the entire zend_auth, not only one user.

Quote:
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$authNamespace->user = $username;
$authNamespace->setExpirationSeconds(360);
Reply With Quote