Home > Uncategorized > Using .asp and cookies to implement a MOTD

Using .asp and cookies to implement a MOTD

February 27th, 2007 Leave a comment Go to comments

code tagIf you want your webpage to display a message of the day (MOTD) for the first time your users access the page and not again until the next day, you can achieve this using a cookie.

Basically, it checks to see if the date stored in the cookie is before today and displays the appropriate page content. Once it has been displayed, it sets the date in the cookie to today to prevent any further display until tomorrow.

' If the date in the stored cookie is before today
< % If (Request.Cookies("CookieName")("LastVisit") < Date) Then %>

This text will only be displayed the first time the page is accessed each day

' Now the message has been displayed,
' set the date in the cookie to today's date
< % Response.Cookies("CookieName")("LastVisit") = Date end if %>

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.