Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Feb 3, 1999

Storing a Last-Modified Date in a Cookie

On informational Web sites, it is often handy to be able to show certain kinds of information only once, and then keep it hidden until it is updated. That way, users don't have to look at the same message every time they come to the site. You can do this by setting a cookie with a version number and an expiration date. Cookies can be set in a variety of ways; one of the easiest is with JavaScript. To set a cookie that records the date a document was modified on, use the following code:
 
<script language="JavaScript">
document.cookie = "modified_date=" + document.lastModified + "; expires Friday, 29-Jan-99 12:00:00";
</script>
This code will store the last modified date in a cookie on the user's machine, and you can refer to it as needed.
Steve Renaker
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date