How to prevent php going back page after log out? [closed]

女生的网名这么多〃 提交于 2019-12-12 16:04:17

问题


I've protected page for 3 level user. level 1--> admin = datapegawai.phplevel 2--> owner level 3--> employee. When I back it after logged out, this page (datapegawai.php) always back.
<?php session_start(); unset($_SESSION['user']); session_destroy();echo"<meta http-equiv='refresh'content='0; url=login.php'>";?>

http://pastebin.com/AvF0PmCk


回答1:


@Ayuktia : You are destroying session. So when you pressing back. Browser is showing cached page. Do following things.

1) Pages which are behind the login, check if session exists. If not redirect it to login page.

2) Use headers that will tell browser not to cache pages which require authentication.

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

3) Use header permanent redirection.

header("Location: login.php",TRUE,302); 
die();



回答2:


don't use echo"<meta....

instead use

header("Location:MynewURL");

(and also after close ? > add a lot of

<!-- dummy --> 

because IE doesn't recognize in a good way the header tag when it had less than some kb



来源:https://stackoverflow.com/questions/27429803/how-to-prevent-php-going-back-page-after-log-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!