![]() |
|
|
Using Cookies to see if our Visitor has been Before<%
If Request.Cookies("BeenHereBefore") = "True" Then When our visitor arrives at our page we check to see If our cookie called BeenHereBefore exists and if it has the value "True". If it does then we set the value of the sMessage variable to "You've been to this page before!". If the cookie doesn't exist and doesn't hold the value "True" then we set sMessage to "Hi, Hope you enjoy this page and come back again!". We also write the cookie BeenHereBefore to the visitors machine. Our cookie also has an attribute, in this case a date when the cookie will expire. It's 60 days from now i.e. 'Now + 60'.
If you do not set the Expires attribute then the
cookie will expire when the user closes their browser. Here's our code in practice: If you get the message "Hi, Hope you enjoy this page and come back again!" click refresh on your browser and see what happens. Read more on Reading and writing cookies If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site. Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|