Skip to content

Instantly share code, notes, and snippets.

@jakemcgraw
Created March 9, 2010 02:47
Show Gist options
  • Save jakemcgraw/326089 to your computer and use it in GitHub Desktop.
Save jakemcgraw/326089 to your computer and use it in GitHub Desktop.
One way to do authorization in Zend Framework
<?php
// .. bootstrap
Zend_Registry::set('identity', new Zend_Session_Namespace());
// .. login
$result = $this->_auth->authenticate($adapter);
if ($result->isValid()) {
$ident = $this->_auth->getIdentity();
$model = new Model_User;
$data = $model->getSessionData($ident);
$identity = Zend_Registry::get('identity');
foreach($data as $fld => $val) {
$identity->{$fld} = $val;
}
}
// .. logout
Zend_Auth::getInstance()->clearIdentity();
Zend_Registry::get('identity')->unsetAll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment