PHP to prevent page back sharing _php instances

Source: Internet
Author: User

For example: Now there are 1,2,3. 3 pages. You want the user to start with the first page, then click Next to see the second page, and then before you go to Page Three, the user cannot
Back off. Let 1 and 2 be the same page. Leave a mark in the session so that:
1and2.php

Copy Code code as follows:

<?php
Session_Start ();
if (Isset ($_get[' P2 ')) {
$_session[' enteredPage2 '] = true;
}
if (Isset ($_session[' EnteredPage2 ')) {
Output page 2. In page 2, the links to Page 3 include the following
Echo is page 2. <a href=\ "3.php\" >Page3</a> this time not back to P1 ~ ";
} else {
Output page 1, contains links to page 2 as follows
Echo is page 1. <a href=\ "p2=\" ">Page2</a>";
}
?>

The following is 3.php, which means that the user has already visited the P2, to allow users to access the P1
Copy Code code as follows:

<?php
Session_Start ();
unset ($_session[' enteredPage2 '));
?>

In the example above, page 1 and page 2 are all 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 about users
will go back 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.