VB icon

Cookie Basics

Email
Submitted on: 1/5/2015 5:49:00 AM
By: Markus D (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: ASP (Active Server Pages)
Views: 495
 
     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.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :Cookie Basics
'**************************************
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:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Cookie Basics
' Description: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.
' By: Markus D (from psc cd)
'
' Inputs:The code asks you to enter a nick/name.
'
' Returns:Once your nick/name is set, every time you goto the page, it'll Say Welcome [Nick]
'
' Assumes: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 
'
' Side Effects:None Known
'**************************************

' 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 "<BR><FORM NAME='message' METHOD='POST' ACTION='THIS_FILES_NAME.asp'><INPUT TYPE='text' NAME='Nick' Size='10' MAXLENGTH='25'>   <INPUT TYPE='SUBMIT' VALUE='Set Nick'>"
end if
%>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.