Let’s assume at us there is a certain page on a site and when the user comes on this page, it should make some actions: to fill fields, something else. The user must finish in 15 minutes. As soon as 15 minutes expired, to execute any action. On client side it is solved simply. But it seems to me it is necessary to do on server(if the user closes page, the timer won’t work).
Details:
When user comes on page that I call controller’s action. In this action I add some record in DB. If the user didn’t finish in 15 minutes, I need to mark these records in a DB.
What is best approach to do this?
Thanks.
Just have a client-side hidden attribute set after 15 minutes that is posted with the user action. If that hidden attribute is present then take no action.
Or, pass in the start time when the page is rendered from the server. Include it in the post. If the time elapsed when the post is made is more than 15 minutes take no action.
If you need to dynamically call the server in 15 minutes and post the data regardless of user input, you are going to have to do a couple things. First, since the user can change their clock to extend the time you cannot expect to get the clock from javascript client side. You will have to have the clock monitored through an AJAX call. Once 15 minutes is up, have the AJAX post the entire page regardless.