[英]In my php project when I clicked on logout, I am redirecting at home page, and if I click back button I am getting back in account page
In my php project when I clicked on logout, I am redirecting at home page, and if I click back button I am getting back in account page, I dont wont to let anyone to come back in account once they clicked logout, which is the best way to do this?.在我的 php 项目中,当我单击注销时,我在主页重定向,如果我单击后退按钮,我将返回帐户页面,一旦他们单击注销,我不会让任何人返回帐户,这是最好的方法来做到这一点? please rply.
请回复。 Thnx
谢谢
It would be useful to know more about the application. 了解有关该应用程序的信息将很有用。
Could it be that your browser is just caching the page? 可能是您的浏览器只是在缓存页面?
Check out this stack overflow link: Browser back button showing the page from cache? 检查此堆栈溢出链接: 浏览器后退按钮显示来自缓存的页面吗?
Add that header to your account page and see if it fixes it. 将该标头添加到您的帐户页面,看看是否可以解决。
Hope this is useful. 希望这是有用的。 Please comment if not.
如果没有,请发表评论。
There are multiple ways to solve this but i could simply do it with a JQuery which would redirect the user somewhere of my choice when i click the back button my browswer. 有多种方法可以解决此问题,但是我可以简单地使用JQuery做到这一点,当我单击浏览器的后退按钮时,它将将用户重定向到我选择的某个地方。 There are plethora of examples if you want but i will include one : link
如果您愿意,有很多示例,但我将提供一个示例: 链接
unset($_SESSION['variable_name']);
或者您也可以销毁会话以注销。
session_destroy();
Destroy the session:销毁会话:
session_unset();//Unset all session variables
session_destroy();
And maybe redirect users if they don't have a valid session.如果他们没有有效的会话,可能会重定向用户。 Add in your header something like
在您的标题中添加类似
if(!isset($_SESSION['valid_user'])){
//Go to some other page
header("Location:$homepage");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.