注销后 点击浏览器后退 又回到登陆后的界面
有三个界面 logon.php / checklogon.php / detail.php / logout.php
logon.php - session_start() 还有包括登陆form等的其他静态html,点登陆了按钮后跳转到checklogon.php.
checklogon.php - 连接数据库并返回用户信息。如果成功$_SESSION['user'] = 用户的相关信息,并跳转到detail.php。
$user = UserBusiness::GetUser($_POST["username"], $_POST["password"]);if($user == null){ header("location: /index.php"); exit;}$_SESSION['user'] = $user;
detail.php - 上面包括了一个注销link,单击后会调用logout.php.
logout.php -
<?php session_destroy(); header("Cache-Control: private, must-revalidate, no-store"); header("Pragma: no-cache"); header("Expires: Sat, 26 Aug 1997 05:00:00 UTC"); header("location: /logon.php"); exit();?>
当点击了logout按钮后,页面到了登陆界面,但是点击浏览器的后退按钮后(IE 8/Firefox),前一个detail界面又显示了。 请问大家如何解决。
当点击后退按钮后,detail.php里面的代码并没有执行,应该是缓存的detail.php有显示了出来。
回复讨论(解决方案)
你这个得贴出detail.php的验证部分来看看
<?php echo('<a href="/Logout.php">Logout</a>');?>
你这个得贴出detail.php的验证部分来看看 贴上了
<?php echo('<a href="/Logout.php">Logout</a>');?>
这个就是?
你里边都没有验证session是否存在的代码,即使你销毁了session又有什么用
修改登陆的PHP,加入如下代码。
<?php session_start(); //使用session存储用户信息 if(isset($_POST["username"])) //数据库中读取username用户名 { $ss_user_id=""; //利用User累的IsValid()方法判断所输入的用户名和口令是否正确 require_once("userclass.php"); //获取用户信息的类 $user=new User(); //如果正确,转到网站首页 if($user->IsValid($_POST["username"],$_POST["password"],$ss_user_id)) { $_SESSION["ss_user_id"]=$ss_user_id; //用户ID echo "<script language='javascript'>"; echo " location='index.php';"; echo "</script>"; } //如果不正确,刷新页面 else { echo "<script language='javascript'>"; echo " alert('用户名或密码错误');"; echo "</script>"; } }?>
修改checklogin.php或者新建一个check.php加入验证用户是否存在代码。
<?php session_start(); if(! isset($_SESSION['ss_user_id'])) //判断是否存在用户ID { echo "<script language='javascript'>"; echo "alert('您的用户无权进行此操作!');"; echo "location='login.html';"; echo "</script>"; exit; }?>
在除登陆和退出页面以外的其他页面文件头处都加上上面这段代码。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Alipay PHP...

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
