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.