如果特定网页同时由另一个人打开,则不允许访问该网页

I have developed a website in which server side coding is done through PHP and I am using MySQL database. There is a specific page on my site that should be opened only once at a time, that is, if it is opened by one person at the same time, the second person should get a message "This page is opened by someone, you can't use it at this time" I thought of a logic that I store timestamp in the database and compare the time from the database and if it's same as that time then it means the page is opened by the other person so access should be restricted. But I don't find this logic reliable. Could there be any other logic that could be implemented?

Obviously this is quite an open question and impossible to give a complete solution to without actually seeing your database/code.

However, here would be a pretty stable logic:

User attempts to access current page.

1) PHP checks DB if session_on_page is not Y.

1a) If Y: Error Message, page in use.

1b) If not Y allow user to access and set session_on_page_user to the users login id or username etc.

2) On page load, start AJAX session that re-logs Y every 5 seconds along with current username.

2.1) Using JavaScript, check for onunload and run a AJAX function that sets session_on_page to N and also wipes session_on_page_user.

That process will be fine if it's simply for viewing data. If there's also any forms/edits being made whilst on the page I would suggest hashing the current time along with user name to create a fairly secure hashkey that is unique to that user and compare it against server time when performing any updates. You may want to go even more secure than this depending on your case scenario. You could use PHP sessions to double check also and potentially even some Apache handling.

Like I said, it's quite a broad question so we can only really give suggestions to logic.