I am trying to figure out how to hide an element to not show again if a user clicks the dismiss button. Basically it is just a drop down with promotional information. If the user clicks dismiss, I do not want this element to show to that user ever again.
I would like it to function like the banner seen here http://codecanyon.net/
Is there a way to do this? I tried Googling this answer but could not really find this example. I am assuming this needs to be achieved with cookies. Also, if that is the case, would that cause any issues with SSL Encrypted pages?
Update: What about just setting a cookie that would expire after so many days?
Here is my code:
<div id="promotional-banner">
<div id="promotional-wrapper">
<div id="promotional-container">
<p class="left"><img src="<?php echo Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL); ?>media/wysiwyg/infortis/fortis/custom/rewards.png" alt="Earn Rewards" title="Earn Rewards" /> Earn reward points every time you shop at WeePumpkin.com</p>
<div class="right close-button"><span>X</span> Dismiss</div>
<div class="clear"></div>
</div>
</div>
</div>
<script type="text/javascript">
$$ = jQuery;
$$(document).ready( function() {
if ($$("#promotional-banner").is(":hidden")) {
$$("#promotional-banner").delay("1000").fadeIn();
}
$$("div.close-button").click(function(){
$$("#promotional-banner").delay("slow").fadeOut();
});
});
</script>
If you mean "forever forever", like when they leave the page and come back, you will need to incorporate a server side technology.
If you have users who aren't registered, you could use PHP (or similar) to capture their IP and mark that IP with a flag. The flags initial state would be 'show' or similar. Once they have clicked dismiss, do a quick jQuery ajax request to your server marking the flag as 'hide'.
Obviously if they changed their IP you're info would be out of date.
You could also use cookies as a solution, but if they cleared their cookies it would be lost.