如何在CakePHP中禁用注销时的缓存

如何在CakePHP中禁用注销时的缓存

本文介绍了如何在CakePHP中禁用注销时的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cakephp 2.3版本。我仅在用户注销时才需要禁用缓存。这是为了防止在按下后退按钮的情况下登录。

I am using cakephp 2.3 version. I need to disable cache only when the user logs out. This is to prevent login in case the back button is pressed.

但是对于其他所有情况,我都不想干扰缓存机制。

But for all other scenarios I don't want to disturb caching mechanism.

现在我在AppController中使用以下函数:

Right now i use the following function in AppController:

public function beforeRender() {
    $this->response->disableCache();
}

但是我怀疑它会完全禁用缓存过程。请帮忙!

But I doubt that it disables the caching process completely. Please help!

推荐答案

如果用户在点击返回按钮后单击返回按钮,我认为该用户不会自动登录到您的网站注销。我是根据您的问题猜测,当用户注销后确实按返回按钮时,您希望他们被转发到登录页面。不幸的是,浏览器可能会缓存上一次访问的页面,并给用户一种他们仍在登录的错觉。请放心,当他们尝试执行需要登录的操作时,会话ID会存储在Cookie中,将不会被识别,它们将被转发到身份验证页面。

I don't believe the user is automatically logged back into your site if they click on the back button after logging out. I'm guessing by your question that when the user does press the back button after logging out, you want them to be forwarded to the login page. Unfortunately, the browser may cache the last page it was on and give the user the illusion that they're still logged in. Rest assured that when they try and do something that requires them to be logged in, the session ID stored in the cookie, won't be recognized and they will be forwarded to the authentication page.

一种可能的解决方法是在注销后将用户重定向到另一个控制器操作-这将引入浏览器历史记录并进行其他过渡。我不知道如果他们单击两次会发生什么。

One possible work around is to redirect the user to another controller action after the logout has taken place - this will introduce and additional transition in the browsers history. I don't know what will happen if they click back twice though.

这篇关于如何在CakePHP中禁用注销时的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 14:17