Today I decided to get to understand cookies better. The easiest way seemed jQuery. I used carhartl's Cookie plugin.
Here's a fiddle.
Basically, what I want is: when a user clicks the 'X', the pop-up closes (works fine) and a cookie is written so that the next time that user hits that page, he doesn't see the pop-up again!
function showPopUp() { var popUpMT = -($("#popUp").height() / 2) - 50; $("#popUp").css("marginTop", popUpMT).fadeIn("slow"); $("#overlay").fadeIn("fast"); } function setCookie() { $("#popUp").fadeOut("fast"); $("#overlay").fadeOut("fast"); $.cookie("popUpCookie", { expires: 365 }); } $(document).ready(function() { var ourCookie = $.cookie("popUpCookie"); if (ourCookie === null) { showPopUp(); } $("#popUp span#close").click(function() { setCookie(); }); });