Write cookie to text box? - 6/28/2001 17:19:00
Hello All, I am using the below code from codeave.com to record a cookie. But when the cookie is read and written back, it is just plain text. I need the cookie to write to a text box...Anyone know how I can do this from the code below?<% response.buffer=true ' response.buffer=true is used to because there is a mix ' of html output and response.cookies when the cookie is written %> <html> <title>CodeAve.com(Cookie Read & Write)</title> <body bgcolor="#FFFFFF"> <% u_input=request.cookies ("testcookie")("u_input") 'checks for the variable u_input from a cookie named testcookie on ' the local pc. ' If the cookie does not exist or have a value for the variable ' then check to see if the user is inputting one if trim(u_input) = "" then u_input=trim(request.form("u_input"))
' If the user hase enetered a value to put to the cookie write it out if u_input <> "" then ' Write the user input to the cookie response.cookies ("testcookie")("u_input") = u_input ' Write the expiration date (today + 3 days) to the cookie response.cookies ("testcookie").expires = DATE + 3
' Read the cookie and write the value of u_input to the browser response.write (request.cookies ("testcookie")("u_input")) %> <p> You text has been written to the cookie.<br> Click <a href="<%= request.servervariables("script_name") %>" target="_blank">here</a> to open this page in a new window. <% else ' If there was no cookie info and there was no value being inputted ' then display the textbox for user input %> <form action="<%= request.servervariables("script_name") %>" method="post"> <input type=text name=u_input> <input type=submit value=Submit> </form> <% end if ' end check for user inputted value else ' if the cookie has a value ' read the cookie and write the value of u_input to the browser response.write (request.cookies ("testcookie")("u_input")) end if ' end check for cookie value %> </body> </html>
|