Zend Framework Login System Step by Step Tutorial - Part 6: At protected page (in previous post), we had created a link to logout. This post talk about logout page.
First, create view for logout. Create a file named "logout.phtml" within application/views/scripts/user. Leave blank (because we don't want to show anything).
Then, we create a method for controller named logoutAction(). Open "UserController.php" within application/controllers. Add following method:
public function logoutAction()
{
$auth = Zend_Auth::getInstance();
$auth->clearIdentity();
$this->_redirect('/user');
}
We just use clearIdentity(). Then redirect page to another page (in this sample to user).
| Series this article: Zend Framework Login: Preparing Database Zend Framework Login: Creating Form Login Zend Framework Login: Creating Authentication Zend Framework Login: Fatal error Cannot use object of type stdClass as array Zend Framework Login: Protected Page Zend Framework Login: Creating Logout Zend Framework Login: Creating Switching for Front Page advertisements blog comments powered by Disqus |

