【问题标题】:Forced Logout action after end of session remember me time会话结束后强制注销操作记住我的时间
【发布时间】:2013-06-06 11:51:09
【问题描述】:

我正在使用 zf2 身份验证方法登录用户。验证用户后,我将用户存储在 2 分钟后过期的会话中。我想要它,以便用户在会话超时后自动注销,无论屏幕上是否出现警告。下面是会话存储的代码。

      if ($result->isValid()) {

                $redirect = 'edit';


                    $this->getSessionStorage()
                         ->setRememberMe(); // sets the session to 2 minutes
                    //set storage again
                    $this->getAuthService()->setStorage($this->getSessionStorage());

                $this->getAuthService()->getStorage()->write($request->getPost('EMAIL'));
            }

【问题讨论】:

  • 没什么可做的。当会话过期时,isAuth() 将返回 false,这意味着用户将不再被登录。
  • 过期后不能重定向到登录页面吗?
  • 一切皆有可能:)。取决于您希望它如何工作。一种解决方案是检查用户是否在每个页面上都经过身份验证。如果他不是,他将被重定向到您的登录页面。尽管使用此解决方案,它不是动态的,但您必须等待用户加载页面。

标签: php session zend-framework2 logout


【解决方案1】:

你不能用 php 做到这一点,因为你需要将请求发送到服务器以检查会话是否过期。您可能必须为此使用js。使用ajax向服务器发送请求以检查会话是否过期并相应地重新加载页面

【讨论】:

    猜你喜欢
    • 2015-03-30
    • 2019-05-04
    • 2018-06-12
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 2018-08-17
    • 2017-11-15
    • 1970-01-01
    相关资源
    最近更新 更多