dongqi7631 2015-11-16 05:15
浏览 24
已采纳

会话从所有浏览器/设备注销

i have this website that maintains users and their profiles, once user logs in, he sees this button to logout.

<a href="<?php echo PSF::urlFor('logout');?>" class="link" id="position">Logout</a>

this goes into this function

 else if($page == 'logout')//when logout occures
        {

            PSF::userLogout(true);


            /**
             * Need to remove twitter session too.
             */

            if(isset($_SESSION['tw_access_token'])){
                unset($_SESSION['tw_access_token']);
            }

            PSF::redirectTo('default_home');                
        }

it logs user out and redirects to homepage, and the PSF::userlogout function looks something like this

 final static public function userLogout($compleLogout = false) 
    {

        if (empty(self::$_userStack)) 
        {
            return false;
        }
        if ($compleLogout) 
        {

            self::$_userStack = array();
            self::requestRemoveCookie('PSF_CookieLogin');
        } 
        else 
        {

            array_pop(self::$_userStack);
        } 

        self::userFlushCache();

        return PSF::sessionSet('__PSF_SYSTEM_CurrentUser_Stack', self::$_userStack);
    }

it is getting current user which is using the browser, and destroys their session and cookies and logs them out successfully BUT from the current browser only, if i open the same account on multiple browsers parallel, it only ends the session on one browser and continues to be logged in on the other browser. i thought removing the session and cookies will destroy the session everywhere and user will be logged out of every other device, is there any additional setting i need to set? or am i missing something?

  • 写回答

1条回答 默认 最新

  • dongshang4984 2015-11-16 06:51
    关注

    A new session is created for each request from the browser if you are using multiple browsers to open site it will create that much of different sessions. You need to store all session user information somewhere in database table and while logout check users Id and delete all the sessions

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值