What do I need to insert in this script for the variable to be cached and after I refresh the page in the browser, the variable stays the same?
<script>
var WishCounter = 0;
$(document).ready(function(){
$(".accordion-heading").click(function(){
if($(".accordion-body").is(':visible')){ /* check the condition accordion-body is visible or not */
$(".accordion-body").slideUp(200); /*if content is visible then close accordion-body with specific time duration */
$(".plusminus").text('+') /* add plus sign */
}
else{
$(this).next(".accordion-body").slideDown(200); /*if content not visible then
show the accordion-body */
$(this).children(".plusminus").text('-'); /* add minus sign */
}
});
$(".add-to-cart2").click(function(){
WishCounter++;
localStorage.setItem('WishCounter', WishCounter);
$(".cart-wish").text(WishCounter);
localStorage.getItem('WishCounter')
});
});
</script>