Why not just have the button target a logoutAction
?
I'm using BjyAuthorise
and ZfcUser
modules but the process of clearing the session and redirecting is the same.
LoginController
public function logoutAction()
{
$this->authService->logout();
$redirect = $this->params('redirect', false);
if ($redirect) {
return $this->redirect()->toUrl($redirect);
}
return $this->redirect()->toRoute(
$this->config->getLogoutRedirectRoute()
);
}
AuthService
public function logout()
{
$adapter = $this->authService->getAdapter();
$adapter->resetAdapters();
$adapter->logoutAdapters();
$this->authService->clearIdentity();
}