Search Tools Links Login

Cookie Basics


The first time the users comes to the page, it'll have a text box and a button. Once you type in your nick and hit Set Nick, it'll display Welcome [the nick they entered]. This is just an example on how-to set/read cookies.

Original Author: Markus D

Inputs

The code asks you to enter a nick/name.

Assumptions

This example is to provide newusers info on how-to use cookies.
request.cookies("Var") - Get's a variable
response.cookies("Var") = "blah" - Set's a varible
"" is like the C command null

Returns

Once your nick/name is set, every time you goto the page, it'll Say Welcome [Nick]

Side Affects

None Known

API Declarations

This code was porduced by Fluid of Fluid Enterprises [http://fluid.hack3r.com]. If may be freely distributed but it would be nice if you contacted me and told that your using it.

Code

' Put this at the top of the page
<%
If (request("REQUEST_METHOD") = "POST") then
Dim Nick
nick = request("Nick")
response.cookies("Nick") = nick
end if
%>
'Put this where you want the Welcome Nick
<%
if request.cookies("Nick") <> "" then
response.write "Welcome "
response.write request.cookies("Nick")
end if
%>
'Put this where you want the text box to appear
<%
if request.cookies("Nick") = "" then
response.write "

   "
end if
%>

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 101 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.