如何处理浏览器“多个”选项卡中的用户注销?从其中一个注销时自动注销所有打开的选项卡 [英] How to handle the user logout in browser multiple tab? auto logout all open tabs when logout from one of them

查看:87
本文介绍了如何处理浏览器“多个”选项卡中的用户注销?从其中一个注销时自动注销所有打开的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友您好,当我从其中一个注销时,我需要自动注销所有打开的选项卡

Hello friends I need to auto logout my all the open tabs when logout from one of them

我已经尝试了以下讨论链接
中的以下代码如何处理浏览器多个标签中的用户注销? / a>

I hava tried following code from this previous discussion link How to handle the user logout in browser multiple tab?

代码:-

<script type="text/javascript">
function readCookie(name) {
    var nameEQ = escape(name) + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) === ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) === 0) return unescape(c.substring(nameEQ.length, c.length));
    }
    return null;
}
window.setInterval(function() {
    if(readCookie('loggedout')==1) {
        window.location.assign('loggedout.html');
        //Or whatever else you want!
    }
},1000);
</script>

我要在所有页面
中放置此代码页脚,而不是在注销时设置cookie。 php by setcookie('loggedout',1)函数
并在登录页面顶部取消设置cookie

I hava place this code footer of all the pages than I set cookies in logout.php by setcookie('loggedout',1) function and unset cookie at top of the login page

但奇怪的是
可以正常工作对于某些页面来说很好,以防万一我下次尝试登录
然后成功登录但在1秒钟后它会自动注销我

but the strange things are it works well for some pages and in case it works next time if I try login then login successfully but after 1 second it logouts me automatically

请让我知道什么这段代码的问题,并且您中的任何一个都对此主题有更好的建议。

please let me know whats the problem with this code and any one of you have better regarding this topic please help me

推荐答案

如何取消设置cookie?

How you unset the cookie??

如果您使用 unset($ _ COOKIE ['loggedout']);

然后将其替换为 setcookie('loggedout');

cookie使用: setcookie('loggedout',1);

That is for set cookie use: setcookie('loggedout',1);

未设置cookie使用: setcookie('loggedout');

for unset cookie use: setcookie('loggedout');

这对我有用。

这篇关于如何处理浏览器“多个”选项卡中的用户注销?从其中一个注销时自动注销所有打开的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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