Home > Backend Development > PHP Problem > How to set the page in php so that it cannot go back

How to set the page in php so that it cannot go back

藏色散人
Release: 2023-03-12 13:52:02
Original
2388 people have browsed it

How to set the page to be unable to go back in php: 1. Open the corresponding PHP page; 2. Set the code "header("Cache-control:no-cache,no-store,must-revalidate");" Disable page regression.

How to set the page in php so that it cannot go back

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

How to set the page in php not to go back?

PHP header() prohibits the page from going back

The code is as follows:

header("Cache-control:no-cache,no-store,must-revalidate");
header("Pragma:no-cache");
header("Expires:0");
header('Location:http://www.xxx.com');
Copy after login

Related introduction:

The header() function sends the original to the client HTTP header.

It's important to realize that the header() function must be called before any actual output is sent (in PHP 4 and above, you can use output caching to solve this problem):

<html>
<?php
// 结果出错
// 在调用 header() 之前已存在输出
header(&#39;Location: http://www.example.com/&#39;);
?>
Copy after login

Grammar

header(string,replace,http_response_code)
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to set the page in php so that it cannot go back. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template