Question

I want to show the user a warning message ('account about to expire') in a div on every page of my site. This I made already in PHP.

Now I want to allow the user to click on a link/image inside the div to hide the div. Then I want the div to stay hidden on all pages for, let's say, 24 hours. Then I want it to show up again, and the user can click it away again (or prolong their membership.)

Should be easy with jQuery and jQuery-cookie I think, but I'm not proficient enough with those.

No correct solution

OTHER TIPS

When the button is clicked to hide it, set:

localStorage['dont-tell-me-about-expiry'] = new Date().getTime();

Whatever name you want in there - I like to keep them descriptive.

Then when you would normally display the box:

if( localStorage['dont-tell-me-about-expiry'] < new Date().getTime()-24*3600*1000) {
    // show the box
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top