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.

我有一个需要登录的网页。一旦用户登录后,我就会启动会话,一旦他注销,我就会销毁它,但当我按下后页时,它会再次给我用户配置文件页面,在理想情况下,用户已经退出了。不过,如果我在退出后重新加载页面,它就可以正常工作。

It's a local chatroom where everybody online and logged in can chat together. There are three pages: login.php, auth.php, logout.php

这是一个本地聊天室,每个人都可以上网聊天。有三页:登录。php,身份验证。php,logout.php

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..

登录。php是一种常见的登录页面。身份验证。php有一个div,它显示之前所有的聊天记录,一个文本框和一个共享按钮,单击该表单将再次发送到auth。因此,每当表单发布时,chatpost就会被发送到数据库,而auth则会在聊天div中重新加载最新的数据库。

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"

现在问题是,一旦我注销了所有的变量并破坏了会话,但即使我在浏览器(Safari)中点击了后退按钮,也就是之前版本的auth。没有最后一个聊天条目的php是可见的,理想情况下不应该破坏会话。我已经在auth中进行了会话验证。php,我想要的是auth。php重新加载用户访问后,将其注销为重新加载auth。php显示“您没有登录”

i have tried

我有试过

<?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.

很抱歉这么长时间的问题,但我真的需要帮助。

6 个解决方案

#1


6

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

更多相关文章

  1. ajax在php页面上获得一个值的结果
  2. php使用DOMDocument更改div但不更新页面
  3. 通过添加3hrs从服务器中重新获取CURTIME()并在PHP页面中显示它
  4. 使用jQuery或Javascript重定向到具有值的给定页面
  5. 来自加载页面的Javascript响应未显示在中,尽管我可以在firebug中
  6. 添加到数据库后,保持在同一页面而不刷新它
  7. PHP的页面布局怎样设计
  8. 如何加载json文件?
  9. 在simplexml_load_file中加载url时出错

随机推荐

  1. Android 布局 & 一些控件
  2. Android(安卓)Material Design动画 View
  3. Android-AbsoluteLayout(绝对布局)
  4. Android 之shape 的用法介绍
  5. Android(安卓)数据存储ContentProvider(类
  6. Android常用第三方框架
  7. Android(安卓)中的观察者模式Observer
  8. Android(安卓)初学者第一步 Activity生命
  9. 安装Android的Eclipse插件ADT遇到错误“r
  10. 【Android】Android Theme的设置