Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Hide div using cookie if page has been already loaded once today?
Old 04-24-2009, 04:00 AM Hide div using cookie if page has been already loaded once today?
Novice Talker

Posts: 9
Trades: 0
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
Error404 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-29-2009, 11:29 PM Re: Hide div using cookie if page has been already loaded once today?
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Use PHP, not JavaScript. The difference between the two is that PHP is server-side, so provided that your server supports PHP (which almost all do), it will work an any computer. JavaScript is client-side, so it will only work if the user has JS enabled (the possibility is low, but still - can't be too safe).

Be aware that you have two different options for this: the afore-mentioned Cookies, and Sessions. Sort of similar to JavaScript and PHP, Cookies are client-side. Meaning that your code will only work if the user's browser accepts cookies. And some browsers have 'security issues' so they won't accept cookies. And, the user may delete their cookies at any time.

Your second option is Sessions. They are server-side, which means that the server will store all the information about whether a visitor has visited in the last 24hrs or not. Plus, the user can't delete sessions like they can cookies. But sessions can be destroyed by the user if they close the browser.

So before you ask for code, make sure you know what you want. There are, of course, a few more unexplored options that would take a while longer to code and set up.

- Steve
__________________
if($stevej == "helpful") { $talkupation += $user_power; }

Last edited by stevej; 04-29-2009 at 11:31 PM..
stevej is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Hide div using cookie if page has been already loaded once today?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13164 seconds with 12 queries