Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1286 How do I display a survey if the user hasn't filled it out previously but not display it if the user has filled it out?

irt.org | Knowledge Base | ASP | Q1286 [ previous next ]

Q1286 How do I display a survey if the user hasn't filled it out previously but not display it if the user has filled it out?

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
%>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.