How does PHP prevent a page. Opened at the same time

Source: Internet
Author: User
How does PHP prevent a page .. How does PHP prevent a page from being opened at the same time .. Opened at the same time .... Is there any way to achieve this... JS .. Thank you ------ solution ------------------ Add the following code to the beginning of the program: PHPcode $ fn _ FILE __. lock; if (file_exists ($ fn) exit (Access Denied); how can fil PHP prevent a page .. Opened at the same time
How does PHP prevent a page .. Opened at the same time .... Is there any way to achieve this... JS .. Thank you.

------ Solution --------------------
Add the following code to the beginning of the program
PHP code
$ Fn = _ FILE __. 'lock'; if (file_exists ($ fn) exit ('Access denied '); file_put_contents ($ fp, ''); ob_start ('unlock '); function unlock ($ buffer) {global $ fn; unlink ($ fn); return $ buffer ;}
------ Solution --------------------
Well, it cannot rely on session control and can be fraudulent.
You can only rely on the server to ensure that the log is unique, and the flock file lock is enough.

PHP code
    
------ Solution --------------------
The landlord may be working on a management system because some management systems have special requirements or are worried about simultaneous insertion.
Use a database. The core is
The IP address (or user ID) must be associated with the path of the current open page, just like a primary key.
OpenUser openPage
1 index. php
2 modules/user/user_list.php
3 modules/user/user_list.php // This is incorrect, because User 1 has opened the "modules/user/user_list.php" page.
------ Solution --------------------
Well, I am worried that he wants a person.Already"Open" is not allowed to "open ".....



Discussion

The landlord may be working on a management system because some management systems have special requirements or are worried about simultaneous insertion.
Use a database. The core is
The IP address (or user ID) must be associated with the path of the current open page, just like a primary key.
OpenUser openPage
1 index. php
2 modules/user/user_list.php
3 modules/user/user_list.ph ......

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.