Reputation: 83
I created a form where a user (not logged in) first of all registers his access in a building with the access' timestamp, then when he leaves he submits again his informations, the form shows him his informations (including arriving time) and allows him to insert leaving time. After compleating the process, the database is updated also with leaving time and the browser is redirected to a home page. My problem is that if the following person presses the "go-back button", he could change the leaving time of the previous person, and I want to avoid this.
Could a cookie mechanism help me? I don't really have ideas of how to manage this problem. I tried to set a coockie before the database update comes and that expires after the update, but with the "go back" button the page isn't refreshed, but it's taken from the cache, and the cookie isn't controlled.
Upvotes: 0
Views: 35
Reputation: 1412
You can not prevent user from clicking the back button of the browser and going back to the previous page.
But as a workaround, what you can do is when the user is redirected to the homepage you can close the current tab and open a new tab so the new tab doesn't have a previous page to go to.
$("#go-to-home-page").on("click", function(){
window.open('http://www.stackoverflow.com','_blank');
window.close();
});
Upvotes: 1