注销后禁用后退按钮 [英] Back button to be disable after logout

查看:89
本文介绍了注销后禁用后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把下面的codeigniter代码为控制器和视图。当用户注销后退按钮不应该去上一页。但我的情况下,它移动到上一页.Pls帮助我解决这个问题。

I have placed below codeigniter code for controller and view.When a user logout the back button should not go to previous page.But i my case it moves to previous page.Pls help me to solve the issue.

控制器登录:

function index()
    {
        $data['main_content'] = 'login_form';

        $this->load->view('includes/template', $data);    

    }
function logout()
    {

         $this->session->sess_destroy();

        $this->index();


    }

查看:login_form

view:login_form

<html>
<head>
 <SCRIPT type="text/javascript">
    window.history.forward();
    function disableBack() 
 {
  window.history.forward();
 }
</SCRIPT></head>
<title>login_form</title>
<BODY onload="disableBack();" onpageshow="if(event.persisted) disableBack();"><div class="container">

            <div class="row">
                <div class="span4 logo">
                   <img src="<?php echo base_url('img/logosl.png'); ?>"  style="margin-bottom:7px; margin-top:7px;"/>
             </div>




<?php $this->load->view('includes/header'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style1.css"  />
<div id="login_form">

    <h1>Login!</h1>
    <?php 
    echo form_open('login/validate_credentials');
    echo form_input('username', 'Username');
    echo form_password('password', 'Password');
    echo form_submit('submit', 'Login');
    echo anchor('login/signup', 'Create Account');
    echo form_close();
    ?>

</div><!-- end login_form-->


<?php $this->load->view('includes/footer'); ?>
</body>
</html>


推荐答案

您的应用程序的页面
(即检查用户是否已从登录页面登录,并且用户具有正确的密钥),如果他不希望他重定向到登录页面。
您可以对您的应用程序应用正确的身份验证。

Instead of disabling back functionality you should check user's authentication on your application's pages (i.e check whether the user has logged in from login page and user has proper keys or not) if he doesn't that he should be redirected to the login page. You could do this by applying proper authentication on your application.

有关更多信息,请访问
http://msdn.microsoft.com/ en-us / library / 532aee0e(VS.71).aspx [^]

for more information go here http://msdn.microsoft.com/en-us/library/532aee0e(VS.71).aspx[^]

这篇关于注销后禁用后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆