Cookies to save

Results 1 to 2 of 2

Thread: Cookies to save

  1. #1
    Join Date
    Dec 1969

    Default Cookies to save

    I know many people have seen the website where there is a splash page where the user selects the country/region to enter. Often the user is given the option to save that selection for future use. I was wondering if someone would know an ASP code to do so. It would really help me out. <BR><BR>Here&#039;s what I have so far:<BR><BR>//Countries drop down from database<BR><BR>&#060;%<BR>Set cnn = server.createobject("ADODB.Connection")<BR>cnn.Ope n "File Name=C:Inetpubudlw2.udl"<BR>strSQL = "SELECT * FROM tblCountries ORDER BY Country"<BR>Set rstCountries = cnn.Execute(strSQL)<BR>%&#062;<BR>&#060;select name="cboCountryID" tabindex="9"&#062;<BR>&#060;%<BR>Do While Not rstCountries.EOF<BR>If rstCountries("CountryID") = "US" Then<BR>strSelected = " SELECTED"<BR>Else<BR>strSelected = ""<BR>End If %&#062;<BR>&#060;option value="&#060;%=rstCountries("CountryID")%&#062;" &#060;%=strSelected%&#062;&#062;&#060;%=rstCountri es("Country")%&#062;&#060;/option&#062;<BR>&#060;%<BR>rstCountries.MoveNext<B R>Loop %&#062;<BR>&#060;/select&#062;<BR>&#060;%<BR>rstCountries.Close<BR>S et rstCountries = Nothing<BR>cnn.Close<BR>Set cnn = Nothing %&#062;<BR><BR><BR>//Cookies to save selection<BR><BR><BR>&#060;%<BR>Const strSaveSelection = "Make this my permanent setting"<BR><BR>Dim strSelected<BR><BR>If Request.QueryString.Count = 0 Then<BR><BR> If Request.Cookies("country").HasKeys Then<BR> <BR> strSelected = Request.Cookies("country")("region")<BR> <BR> Response.Redirect("") <BR><BR> Else<BR><BR> strSelected = ""<BR><BR> End If<BR><BR>Else<BR><BR> strSelected = Request.QueryString("region")<BR><BR> If Request.QueryString("save") = strSaveSelection Then<BR><BR> Response.Cookies("country")("region") = strSelected<BR> <BR> End If<BR><BR>End If<BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Cookies to save

    The way I would do it<BR>On your form make a checkbox next to the selected country (call it "Make this my permanent setting"). When submitted you save two keys in your cookie. One called Country which contains the name of the selected country and one called AutoCountry wich is True or False. When your page loads you check the cookie, if the AutoCountry is true then you select the stored country and proceed.<BR><BR>Response.Cookies("MyCookieName")(" Country") = strSelected<BR>Response.Cookies("MyCookieName")("A utoCountry") = bolAutoCountry<BR><BR>You might have to write a little code to convert your checkbox to True/False.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts