您重新定向到登錄頁面,並保存網頁網址進行登錄請求這是index.php?logout
重新回到直接存在,如果從返回URL中移除例如
//replace parent::$Patch with your root url like "http://localhost/myapp/"
if(!parent::$Patch.'admin/login.php'=='http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']){//check if you are in login.php page didn't redirect to login.php
if([email protected]('Location:'.parent::$Patch.'admin/login.php?url='.rawurlencode(str_replace("logout","",'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])))){
//if header error echo javaScript code for re-direct
?>
<!DOCTYPE HTML>
<html>
<head>
<script language="javascript">
var LoadP = <?php print "'".parent::$Patch.'admin/login.php?url='.rawurlencode(str_replace("logout","",'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']))."'"?>;
self.location = LoadP;
</script></head></html>
<?php
}
exit();
}
}
這個代碼重新定向用戶到登錄頁面,並保持頁面的返回URL必須檢查周邊logout
。如果回報內部存在logout
URL刪除
我希望它可以幫助你
謝謝你的例子,但是,location.reload不適合我,但是,location.href爲我..btw工作,感謝分裂函數,它爲我工作.. :) –
歡迎傢伙:-) –