[英]Codeigniter, redirect to previous page when back button browser is click
I want to be when the back button on the browser is clicked. 我想当单击浏览器上的后退按钮时。 system will redirect to previous page or to a specific page. 系统将重定向到上一页或特定页面。
I've made a function to check the login session like this 我做了一个检查登录会话的功能,像这样
public function cekAuth(){
/* Mengecek login session
*/
$sesi = $this->ci->session->userdata('isLogin_'.project);
$key = $this->ci->uri->segment('1');
if ($sesi == TRUE && $key == "access") {
redirect('dashboard/home');
exit();
} else if($sesi == FALSE) {
redirect('access');
exit();
}
}
if the login session is TRUE and the user accesses the login page will be redirected to the dashboard. 如果登录会话为TRUE并且用户访问登录页面,则将重定向到仪表板。 This has been successfully. 这已经成功了。
but when I logout always redirected to the dashboard and not to the login page. 但是当我注销时,始终重定向到仪表板而不是登录页面。
LOGOUT: 登出:
function logout(){
$this->session->sess_destroy();
$this->session->set_userdata('isLogin_'.project , FALSE);
redirect('access');
}
Can you help me? 你能帮助我吗? :) :)
It would be great first please check your condition is perfect or not, May be if you will do on this ways get idea where is problem. 最好先检查您的状况是否理想,或者是否可以通过这种方式了解问题所在。
public function cekAuth(){
/* Mengecek login session
*/
$sesi = $this->ci->session->userdata('isLogin_'.project);
$key = $this->ci->uri->segment('1');
if ($sesi == TRUE && $key == "access") {
echo '1';
exit();
redirect('dashboard/home');
} else if($sesi == FALSE) {
echo '2';
exit();
redirect('access');
}
}
Change this line in logout
function: 在logout
功能中更改此行:
$this->session->set_userdata('isLogin_'.project , FALSE);
To 至
$this->session->unset_userdata('isLogin_'.project , FALSE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.