-1
I have a page that makes queries by dates, with the date selected the page returns me the result, until then ok, but then the client requested to keep the date as a history so that he did not need to choose the same date every time.
The code I made was this:
$('#dataCons').on('blur', function() {
var cod = $(this).val();
window.location="admagendamento.php?dataEsc="+cod;
sessionStorage.setItem("dataEsc", cod);
});
This is when I choose the date in the field, besides the search it still stores the date in the sessionStorage, but in a next page load when I check if there is already a date inside the sessionStorage, and if there is executed the search with that saved date the page enters in loop, see the code:
$(document).ready(function() {
var dataEsc = sessionStorage.getItem("dataEsc");
if (dataEsc){
window.location="admagendamento.php?dataEsc="+dataEsc;
}
How do I stop the page from looping?
I believe that if you save this data in a cookie would be much nicer.
– Luciano Alves