代码点击器中的注销问题(PHP) [英] logout issue in code igniter (PHP)

查看:169
本文介绍了代码点击器中的注销问题(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将loginuserid存储在会话中并在注销时销毁会话。登录和注销工作正常,但我的问题是当用户注销,我们按回按钮它仍然能够打开访问的页面,甚至当他实际上被遗弃。

I am storing loginuserid in session and destroy session on logout . login and logout work fine but my problem is when user logout and we press back button it still able to open visited page and even when he is actualy loged out .

当我们刷新页面时,用户转到登录页面。我想用户不去访问的页面,即使他按回来按钮。请帮助我。

User go to login page when we refresh the page . I want user not go to visited page even he press back button . Please help me out . Thanks in Advance .

推荐答案

页面显示的原因是浏览器从缓存中提取它。要指示浏览器不要从缓存中显示您的页面,您可以在< head> 中添加 no-cache code>您应用程式的每个安全网页:

The reason the page shows is that the browser is bringing it from the cache. To indicate the browser that it should not show your page from the cache you could add the no-cache meta tag inside the <head> of every secure page of your app:

<meta http-equiv="Cache-Control" content="no-cache" />

如果你不想避免缓存,另一个替代方案对服务器进行AJAX调用,检查每次打开安全页面时用户是否登录。像这样:

Another alternative (a little convoluted) if you don't want to avoid caching, is to have javascript make an AJAX call to the server checking if the user is logged-in every time you open a secure page. Something like this:

$.getJSON('/user_logged_in.php', function(loggedIn) {
    if(!loggedIn)
        window.location.href = '/login.php';
});

user_logged_in.php 脚本应该返回TRUE或FALSE。

The user_logged_in.php script should return TRUE or FALSE.

希望这有助。

这篇关于代码点击器中的注销问题(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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