You are here: irt.org | FAQ | ASP | Q1286 [ previous next ]
The following was submitted by Marc W
Let's say you have a survey that you want first time users to fill out, but you don't want to annoy them by going to the survey every time they stop by. Cookies are a great way to take care of this problem w/out worrying about dealing with a database.
<%@ LANGUAGE="VBSCRIPT"%> <% 'Request cookie as variable QQSurvey Survey=Request.Cookies("QQsurvey") 'Check to see if a cookie exists If Survey="" then 'If no cookie exists, then we create it and set it so that it 'doesn't expire for a while so they won't be sent to survey.asp 'next time and then we redirect them to survey.asp this time Response.Cookies("QQsurvey")="QQ" Response.Cookies("QQsurvey").Expires=#January 01, 2010# Response.Redirect "Survey.asp" 'If the cookie exists, then we redirect them to anypage.htm Else Response.Redirect "anypage.htm" End If %>