开发者

Problem with browser forward and backword button

My problem is that when I login my application and store user id in session after that I press browser back button to go again login page and that state (logged in) I check my login page if any user exists then call log out function to log out and same checking when user logged in and press backward then press forward. But both situation my application shows the previous logged in page.

I want that when user login successfully and view the success page that state to press browser back button and reach the login page the user automatically log out and no work to forward button click (disable forward button).

Same works on when user logged in and click to log out link and destroy all session data and reaches to login page that state to 开发者_如何学Pythonclick browser forward button no works (disable).Firefox, chrome and IE works well on after log out forward and backward disable and fulfill my wants but Opera, Safari and other browser have problem. Please help me. Here is my code snippet

//Login function
public function index(){

$data = array();

if( $_SESSION['companyId'] ){
$this->logout();
}

$data['company'] = $this->Main->getCompany();               
echo $this->load->view('auth/login', $data);
}

//login success function
public function login(){

$data = array();

$username = $this->input->post('username');         
$company_id = $this->input->post('company');            

if($_SESSION['companyId']){
    $company_id = $_SESSION['companyId'];
}

$_SESSION['companyId'] = $company_id;         

$this->layout->view('auth/index', $data);               
}

//Log out function
public function logout()
{
session_destroy();
    redirect(base_url().'index.php/auth/index'); 
}


You can't do it in php. php is server side, and "back" on a browser reloads the browser's cached previous page, so of course it's the same.

If you want anything like that, you'll have to use javascript and hope that no one disables javascript. Either way, a "back" button on the browser is a poor way to log out. What's wrong with a log out button?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜