Method: Determine whether there is a session when accessing the page. If not, create a session directly and set it to the current time. The program will execute normally; if there is a session, determine the time difference between the time in the session and the current time. , if the interval is less than the specified time, program execution is interrupted.
php method to prohibit page refresh
Method 1:
A small piece of code to prevent page refresh may not be of much use, it is just an idea for reference.
Principle:
Determine whether there is a session when the page is accessed. If not, create a session directly and set it to the current time. The program will execute normally;
If there is session, determine the time difference between the time in the session and the current time. If the interval is less than the specified time, such as 5 minutes in this example, the program execution will be interrupted and an error message will be prompted;
If the time in the session is greater than the current time time, refresh the time in the session, and the page will execute normally.
The code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Method 2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Recommended related tutorials: "PHP Tutorial》
The above is the detailed content of How to prevent page refresh in php?. For more information, please follow other related articles on the PHP Chinese website!