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


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-25-2008, 12:13 AM
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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-25-2008, 03:03 PM
Elemental's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 119
Default

Are you saying that when you expire the session it logs other users off as well? It should only expire the session for one user which would effectively log that user off. I'm not sure I understand what your problem is.
__________________
Zend Framework Resources: Zend Webinars | Reference Manual | API Docs | Books | FreeNode: #zftalk
Getting Started Tutorials: Getting started with ZF | Getting started with Zend Auth

Last edited by Elemental : 04-25-2008 at 03:19 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-25-2008, 04:22 PM
Junior Member
 
Join Date: Dec 2007
Posts: 4
Default

Yes. once the session expire,
it will expire all the user.
does the following code correct to use?

PHP Code:
$authNamespace = new Zend_Session_Namespace('Zend_Auth');
$authNamespace->user $username;
$authNamespace->setExpirationSeconds(360); 
or I have to create new namespace for each user?
PHP Code:
$authNamespace = new Zend_Session_Namespace($username); 
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 11:51 AM.