Debt Consolidation - Find jobs - Debt Consolidation - Loan - Wordpress Theme

PDA

View Full Version : Hide div using cookie if page has been already loaded once today?


Error404
Apr 24th 2009, 12:06 am
Hi,
First, I am absolute javascipt newbie so please threat me like that.. :)))

I need the following functionality to my webpage:

Let's say I have a div with some unique ID on my page.
Now, what I need is to show this div on my page only the first time visitor opens a page, and then not show it every next time he/she opens it for next 24h.

So I need to set a cookie that hides div from page if it has already been shown to visitor, for next 24h, so that the content of this div will be shown to each unique visitor only once for a day.

Thanks in advance... ;)

Nikola

PoPSiCLe
Apr 25th 2009, 10:15 am
You might wanna look to serverside scripting for that - it's very easy to do in PHP, for instance.

All you would have to do there is set the cookie, and then later check if the cookie exist:
if (isset($_COOKIE['hidediv'])) {}
else { echo "<div>something here</div>";}

JavaScriptBank.com
Apr 27th 2009, 11:29 pm
cookie also is very easy to use, view source code of script below to solve your problem

- Only Popup Once (http://www.javascriptbank.com/javascript/cookie/only-popup-once/detail/)