問題描述
我有一個需要登錄的網頁.一旦用戶登錄,我就開始會話,一旦他退出,我就會銷毀它,但是當我按下后頁時,它再次為我提供了用戶配置文件頁面,理想情況下不應該是這樣,因為用戶已注銷.但是,如果我在注銷后重新加載頁面,它就可以正常工作.
I have a webpage that requires login. Once a user has logged in I start the session and once he logs out I destroy it, but when I press the back page it gives me the user profile page again which ideally should not be the case as the user has logged out. However, it works fine if I reload the page after logging out.
這是一個本地聊天室,在線和登錄的每個人都可以在這里聊天.一共有三個頁面:login.php
、auth.php
、logout.php
It's a local chatroom where everybody online and logged in can chat together. There are three pages: login.php
, auth.php
, logout.php
login.php
是包含表單的常見登錄頁面.auth.php
有一個 div
顯示所有以前的聊天直到現在,一個文本框和共享按鈕,點擊后一個表單被再次發送到 auth.php 所以每次表單是發布聊天帖子將發送到數據庫,并使用聊天 div 中的最新數據庫重新加載身份驗證..
login.php
is the common login page containg a form. auth.php
has a div
displaying all previous chats up til now, a textbox and share button on clicking which a form is sent again to auth.php so everytime the form is posted the chatpost is sent to database and auth is reloaded with the latest database within the chat div..
現在的問題是,一旦我注銷,我就會取消設置所有變量并銷毀會話,但即使如此,如果我在瀏覽器 (Safari) 中按下后退按鈕,之前版本的 auth.php
沒有最后一個聊天條目是可見的,理想情況下不應該因為會話被破壞.我在 auth.php
中放置了一個會話驗證,所以基本上我希望 auth.php
重新加載用戶在重新加載 auth 后注銷后訪問它.php
顯示您尚未登錄"
Now the problem is once I logout I unset all the variables and destroy the session but even then if I hit the back button in browser (Safari), the previous version of auth.php
without the last chat entry is visible which ideally should not as the session is destroyed. I have put a session validation in auth.php
, so basically I want the auth.php
to reload of the user visits it after logging out as reloading auth.php
displays that "you are not logged in"
我試過了
<?php header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
and
<head>
<meta http-equiv='Pragma' content='no-cache'>
<meta http-equiv='Expires' content='-1'>
</head>
抱歉問了這么長的問題,但我真的需要這方面的幫助.
Sorry for the lengthy question but I really need help on this.
推薦答案
這些標頭將強制瀏覽器和代理(如果有)不緩存頁面并強制向服務器發送該頁面的新請求:
These headers will force the browser, and proxies if any, not to cache the page and force a new request to the server for that page:
header("Cache-Control: private, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // A date in the past
這篇關于點擊后退按鈕重新加載頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!