View Full Version : Cookies Question from a newbie
03-26-2006, 03:50 PM
Listen, I have a form that is created with normal text inputs, radio buttons and drop down menus. This page is a HTML page. Than on submit goes to the process ASP page. Now to create and check if there are any cookies already where does the code go. I've been to several pages and understand the codes I just don't know if they go in the HTML page or the ASP page. The page already validates the data etc. I just need to know where I need to put the creation and checking of the cookies!
I hope you can understand what I'm trying to do. Please help me if you can to just tell me what part goes where! Thanks in advance!:)
03-26-2006, 05:46 PM
03-27-2006, 01:37 PM
Use an If/Else statement to check if the cookie exists, if not create it.
If Request.QueryString("setcookie") = "set" Then
Response.Cookies("fname") = "Degsy"
Elseif Request.QueryString("setcookie") = "del" Then
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%If Request.Cookies("fname") = "" Then%>
<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?setcookie=set">Set Cookie</a>
fname = Request.Cookies("fname")
<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?setcookie=del">Delete Cookie</a>
03-28-2006, 09:34 PM
Okay, if you only want your ASP Process page to search for the cookies then it needs to go into the ASP portion of that page. My question is if your tracking itemS then why not use sessions first, cookies can become your worst nightmare.... second typically for everytime I have been needing to track something in a session / cookie the need has been for every page. If thats the case then it changes your situation entirely. For that case you would need to make all the pages ASP pages, and then either make the validation / cookie checker in a separate include file. Probably more confused from my answer but I just dont see the need of checking cookies if its a one time process page.
03-28-2006, 10:27 PM
ASP sessions are unwritten cookies. The problem is they use server memory. So if you have a lot of session variables you will drag your site's response time down. Sessions can be great if used properly but they can also be a nightmare.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.