PDA

View Full Version : Retrieving Value from Cookie


Corey Bryant
08-20-2003, 02:51 AM
I have this code that creates a cookie:

<%
'******************************************
' declare variables
'******************************************
dim affID
dim arriveDate
dim sql
dim oRs
dim signupDate
dim Company
dim amount
dim IPAddress
dim paid


'******************************************
'Collecting and giving the variables values
'******************************************
affID = trim(Request.QueryString("affID"))
arriveDate = FixDate(date())

'******************************************
'tasks to perform
'******************************************
If affID <> "" then

' cookie creation
Response.Cookies("AffInfo") = affID
Response.Cookies("AffInfo").Expires = Now() + 30

'session creation
Session("affID") = affID

'data functions
Call OpenDB()

sql = "ins_spAffLog '" & affID & "','" & arriveDate & "','" & signupDate & "','" & Company & "','" & amount & "','" & IPAddress & "','" & paid & "'"
Set oRs = dbConn.Execute(sql)

'oRs.Close
'Set oRs = Nothiing

Call CloseDB()

End if
%>

When they finally get to the form to submit an application, what code for the input should I use to retrieve the value?

Thank you!

glenngv
08-20-2003, 03:46 AM
info = Request.Cookies("AffInfo")
response.write(info)

Corey Bryant
08-20-2003, 04:25 AM
unfortunately I know very little at what is going on here. I put this input field after the form tag:
<input type="hidden" name="Affiliate" size="50" value="<%response.write(info)%>">

The info = Request.Cookies("AffInfo") do I dim this? Or just put it before the <Head> at some point? Thank you!!

glenngv
08-20-2003, 04:46 AM
Of course, put the server-side code inside <% %> delimeters and put them anywhere above where you want to access it.

<%
info = Request.Cookies("AffInfo")
%>
...
<input type="hidden" name="Affiliate" size="50" value="<%=info%>">

Corey Bryant
08-20-2003, 04:48 AM
Much obliged! that is what I thought, but I am always afraid of where my brain might send me. :D

whammy
08-22-2003, 09:48 PM
http://www.w3schools.com/asp/asp_cookies.asp