I have created a pages login , logout to access a control panel
scenario goes like this: user logs in and accesss the cpanel page and them logs out
Problem : when login is done if user click on browser back button user goes back to login page even though authentication is done and sessions are set, at the same time if user logout , and click back button it will return back to control panel page (if user refresh the page then everything seems to be fine and usr will be redirected to login and back button won’t redirect her to cpanel ) .
The problem is browser cache , I tried with both php header and html meta to prevent the page from caching but I could not succeed . Any solution to this?
My logout action code is as follow
public function logoutAction()
{
$auth=Zend_Auth::getInstance();
//If logged in then move to index
if(!$auth->hasIdentity()){
$this->_redirect('admin/account/redirect');
}
$auth->clearIdentity();
$this->_redirect('admin/account/redirect');
}
You could always run a piece of javascript onLoad that requests another PHP page using AJAX and then if the user is logged in then redirect them back to the CPanel or Login page, wherever they are supposed to be.
JQuery post would handle this quite nicely.
http://api.jquery.com/jQuery.post/