I saw a function in various web applications, including Wordpress (not sure?), Which alerts the user if he opens an article / message / page / regardless of the database, and someone else is editing the same data at the same time.
I would like to implement the same function in my application, and I thought a little. Is the following example a good practice on how to do this?
This is a bit like this:
1) User A goes to the edit page for the cryptic article X. The Events database table has been programmed to ensure that no one else is editing the same page at the moment, which no one belongs to. The token is then randomly generated and inserted into a database table called Events .
1) User B also wants to make updates for article X. Now that our User A already editing the article, the Events table is requested and looks like this:
| timestamp | owner | Origin | token | ------------------------------------------------------------ | 1273226321 | User A | article-x | uniqueid## |
2) The timestamp is checked. If it is valid and less than 100 seconds, a message appears and the user cannot make any changes to the requested article X:
Warning: User A is currently working with this article. In the meantime, editing cannot be done. Please do something else with your life.
3) If user A decides to continue and save his changes, the token is sent along with all the other data to update the database and switches the request to delete the row using the uniqueid## token. If he decides to do something else instead of making his changes, article X will still be editable in 100 seconds for User B
Let me know what you think of this approach!
Wish everyone a great weekend!