Limit number of sessions using a page


Is there a way to limit the number of sessions that can have a certain page open at the same time?
I have some pages dedicated to modify tables in SQL and I want to limit the concurrent users as much as possible to avoid parallel modifications.

Maybe looping trough all opened sessions and checking if there is "space" for the specific page to be opened and if not just redirect the page to a "waiting page" with a message "Max number of sessions. Please wait until another user closes the page" and a refresh button to re-run the action.

That's not how the web works. I think there is something wrong with your strategy and you need to use a record lock or similar when the first user starts to edit.

You are right in being weary of this kind of power to "modify tables" from a web app. I would suggest you add audit log tracking to capture all changes users are making.

In the past a solution that worked for me in this situation is to have a "[pageName]/login" tag for that specific page. I put a login/logout button on that page that writes/erases your userID to that "pageName]/login" tag. Users can only make changes to that data if your userID matches that tag value.

I had to do something similar a while back. Instead of locking things down. I alerted via popup if two or more users were editing at the same time. I did this with messages.