Search code examples
phpzend-frameworkauthenticationzend-auth

Updating Zend_Auth_Storage after edit users profile


I have following situation: I have loged user, standard authentication with DB table

$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter()); 
$authAdapter->setTableName('users'); 
$authAdapter->setIdentityColumn('user_name'); 
$authAdapter->setCredentialColumn('password'); 

When user edits his profile, I save it into Db, but I need to update also storage (using standard Zend_Auth_Storage_Session). Is there any easy way how to do it? Many thanks.


Solution

  • Your best bet would be to not use Zend_Auth's storage to hold information that's likely to change - by default it only holds the identity (for good reason). I'd probably make a User class that wrapped all the Auth, ACL (and probably profile) functionality that uses a static get_current() method to load the user stashed in the session. This bypasses all the consistency issues you run into when stuffing it into the session as well as giving you a single point from which to implement caching if/when you actually need the performance boost.