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– Community Bot2023年09月28日 17:05:57 +00:00Commented Sep 28, 2023 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');
console.log(get_date);
Compare the current date and storage date to write your logic. 
If the condition is not fulfilled, Disable the submit button.
Explore related questions
See similar questions with these tags.