PHP to prevent page back from sharing methods

Source: Internet
Author: User
Tags php code

This article mainly introduces the PHP blocking page back method, so that the back of the page does not exist to prevent the page back, how to make the page does not exist, the temporary generated page can be, the following examples illustrate this method

For example: Now there are 1,2,3. 3 pages. You want the user to start with the first page and then click Next to see the second page, and then before you go to Page Three, the user cannot step back. Let 1 and 2 be the same page. Leave a mark in the session, so: 1and2.php code is as follows: <?php session_start (); if (Isset ($_get[' P2 ')) {$_session[' enteredPage2 '] = true;} if (Isset ($_session[' EnteredPage2 '))) {//Output page 2. In page 2, include The link to Page 3 is as follows echo "This is page 2." <a href= "3.php" >Page3</a> this time back less than P1 ~ "; else {//Output page 1, contains the link to page 2 as follows echo "This is page 1. <a href= "p2=" ">Page2</a>"; ?> Below is 3.php, the role is to indicate that the user has visited the P2, to allow users to access the P1 code as follows: <?php session_start (); unset ($_session[' enteredPage2 '); In the above example, page 1 and page 2 are temporary pages generated by 1and2.php. When the user's browser to read this address, you output page 2 is page 2, do not worry that users will return to page 1. This is the most fundamental solution that is not browser-independent.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.