Studyon Minte9.com
ZF 1.0




Logout



#Application/modules/default/controllers/FrontendController.php
<?php
class FrontendController extends Zend_Controller_Action {

	public function indexAction() {
		$this->view->message = "Hello world";

		$auth = Zend_Auth::getInstance();
		if ($auth->hasIdentity()) {
			$logoutUrl = $this->view->url(array(
				'module' => 'user',
				'controller' => 'auth',
				'action' => 'logout',
			), null, true);

			echo '<br><br> Welcome <i>' . $auth->getIdentity()->username . '</i> ';
			echo '<a href="'.$logoutUrl.'">Logout</a>';
		}
	}


#Application/modules/user/controllers/AuthController.php
<?php
class User_AuthController extends Zend_Controller_Action {
	
	...

	public function logoutAction() {
		Zend_Auth::getInstance()->clearIdentity();
		$this->_redirect(_APP_URL . '/user/auth/login');
	}
}