I have enabled admin_actions in my cakePHP project. I have a logout() for normal employees and admin_logout() for admin logout. Both actions belong to EmployeesController.
The code inside both logout actions is the same,except for the flash message.
admin_logout():
$this->Session->destroy();
$this->Session->setFlash('You have been logged out of admin dashboard!','flash_success');
$this->redirect('/employees/login');
logout()
$this->Session->destroy();
$this->Session->setFlash('You have been logged out!','flash_success');
$this->redirect('/employees/login');
The logout is working perfectly and destroys the session. But not the admin_logout().
For debugging, i tried this in admin_logout():
$this->Session->delete('Admin');
$this->Session->setFlash('You have been logged out of admin dashboard!','flash_success');
$this->redirect('/employees/login');
It is also working. But it still wont destroy the complete session variable. I could fix this by using normal logout() for both admin and employee. But out of curiosity, whats going wrong here?
EDIT: Needed behavior is the destruction of session variable, then redirection with flash message. But what happens is redirection and flash message is getting displayed BUT session var is not getting destroyed!