I believe it can be done with a PHP controller or JS cookie manipulation. Help me with logic. For example, I want a user to send a request once every 2 minutes.

Let's pretend I've implemented some logic in the PHP controller and when I click the form Submit button in a custom product view tab, it says "You have already submitted a request in the past 2 minutes. Please try again later"

  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Sep 28 at 17:05

1 Answer 1


1. Using PHP In the controller, Insert the current date and time into the cookie.

If the user clicks on the submit button the first time set the cookie and the second time check cookie is set or not.

If the cookie sets and compares the current date time with the cookie date time is greater than 2 minus the perform the action otherwise returns an error message.

2. Using jQuery

Logic same as PHP controller. In jQuery use localStorage to set current data and time for the compare.

Set current date into localStorage
var currentTime = new Date();

localStorage.setItem('storage', currentTime);   

Get date from localStorage
var get_date = localStorage.getItem('storage');

Compare the current date and storage date to write your logic. 
If the condition is not fulfilled, Disable the submit button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.