HTML Online Tutorial Contents

Following are the posts for HTML online Tutorial. To learn everything about HTML, just read these posts: HTML Online Tutorial HTML TAGS (2) HTML BASICS (3) HTML ELEMENTS (4) HTML ATTRIBUTES (5) More »


XHTML stands for Extensible Hypertext Markup Language. It is also known as XML (Extensible Markup Language). It is a markup language. In XHTML, there are no predefined tags. The user defines the More »


In this tutorial, you learned: HTML Introduction HTML Tags HTML Basics HTML Elements HTML Attributes HTML Paragraphs HTML Headings HTML Formats HTML Image HTML Links HTML Lists HTML Frames HTML Table After More »


HTML Tables are used to arrange data in web pages. HTML allows the use of tables by <table>…</table> tags. Each row in HTML table is recognized by <tr>…</tr> tag. In each row More »


Nested frames example: For the following example to work, there are two other simple HTML files : “HMTL11e1 frame a.html” and “HMTL11e1 frame b.html”. your browser will divide your screeub half. The More »


Tag Archives: asp cookies retrieval

ASP Cookies

Learn about ASP Cookies (10 ASP):

A cookie is basically a small file which is embedded on the user computer by the server to identify the user. This cookie is send with every request that user make for a particular page using any web browser. One of the many advantages of ASP is to both retrieve and create different cookie values. Following is the brief method of crating cookies in ASP:

The command that is used to produce cookies is:    “Response.Cookies”. This command should be written before the HTML tags in the file. (<html>).  The syntax for creating cookies is following:


Response.Cookies”name of cookie”=”value of cookie”.


There are different properties that any cookie can have for example the expiry date of the cookie.  Following is the example where a cookie named “website-school” is created with the value “ASP Tutorial” and will expire on 03/01/2012:


Response.Cookies” website-school”=” ASP Tutorial”.

Response.Cookies” website-school”=” ASP Tutorial”.Expires=#January 03,2012#


Now comes the part where you get to learn how to get the cookie. The command which is used to retrieve any created cookie is “Request.Cookies”. You can request the value of cookie and store it in a variable (Cookievariable) and then print it later. Following is the syntax used for this purpose:


Cookievariable=Request.Cookies(”name of cookie”)

Response.write(”name of cookie” & Cookievariable)


The following example will retrieve “website-school” and print its value:



Response.write(”website-school” & Cookievariable)


Output of this example will be:

website-school = ASP Tutorial


Now, some information about cookies with keys….

If any cookie comprises of more than one value, then such cookie is known as a cookie with keys. The syntax for doing so is:


Response.Cookies(”name of cookie”) (“sub name”)=”value of cookie”.

Response.Cookies(”name of cookie”) (“sub name1”)=”value of cookie”.


Following cookie will display cookies with keys of a user containing his name, age and sex:


Response.Cookies(”user1”) (“name”)=”Muntaha”

Response.Cookies(”user1”) (“age”)=”22”

Response.Cookies(”user1”) (“sex”)=”Female”


Reading all cookies send by a server will be very troublesome. Don’t worry there is a solution  to read all the cookies send by a server. But to do this we will use Request.Cookies.HasKeys property.  Following is the syntax to do this:

<script type=”text/javascript”><!–
google_ad_client = “ca-pub-7789281879799866”;
/* webpost */
google_ad_slot = “1930114734”;
google_ad_width = 300;
google_ad_height = 250;
<script type=”text/javascript”


dim a,b
for each a in Request.Cookies
if Request.Cookies(a).HasKeys then
for each b in Request.Cookies(a)
response.write(a &b& “=” & Request.Cookies(a)(b))
response.write(“<br />”)
Response.Write( “Start”)
end if
response.write “</p>”

The output of this code will be as following:


Some of the browser does not support cookies. Then passing information via these browser is impossible. So the two alternative ways of passing information are:

  • You can either add Parameters to the URL.
  • Or you can use a form to do so


By using the forms, user can enter the information and then clicks the “Send” button. Following is the way with which you can add parameters to the URL:

<form method=”post” action=”none.asp”>
user Name: <input type=”text” name=”name” value=”” />
user age: <input type=”text” name=”age” value=”” />
<input type=”submit” value=”Submit” />

Similarly the retrieval of these cookies can be done in following way:

response.write(“<p>” & name & ” ” & age & “!</p>”)

Similarly the information can be passed by adding parameters to the URL.

<a href=”none.asp?name=Muntaha & age=22″>Go to none Page</a>

The retrieval of these cookies can be done in following way:

response.write(“<p>” & name & ” ” & age & “!</p>”)

For more visit next posts in this category.To go back to Contents of this tutorial: ASP Active Server Side Scripting Contents